Prev: float inexact result
Next: Spritley Old Guy
From: Clive Lumb on 16 Mar 2010 03:50 "Bee" <Bee(a)discussions.microsoft.com> a écrit dans le message de groupe de discussion : 427E1D2E-2405-4406-984F-6B0EBF0E4B22(a)microsoft.com... > I am fiddling with this piece of code i got from someplace. I can't > remember > where. Some time ago. Thanks to whomever for the snippet. > > It works for pure ASCII text that I have tried. > I am trying to get it to work on .RTF text but I do not understand enough > to > get it going. > Someone please show me how to do this. > If this is not possible, then what is another fast method. > This is only for a paragraph or so of text. > > The text may be coming from a "string", a TextBox or a RichTextBox. > If it is from a RichTextBox i want to preserve all the formatting. > > Public Function CryptoEasy(sPlaintext As String) As String > ' > ' Same routine to encrypt and decrypt > On Error GoTo CryptoEasyErr > > Dim n As Long > Dim C As Long > > CryptoEasy = StrReverse(sPlaintext) > For n = 1 To Len(CryptoEasy) > C = Asc(Mid$(CryptoEasy, n, 1)) > > Mid$(CryptoEasy, n, 1) = Chr$(C) > > If C > 32 Then > If C > 127 Then > C = 383 - C > Else > C = 160 - C > End If > Mid$(CryptoEasy, n, 1) = Chr$(C) > End If > Next > > CryptoEasyExit: > Exit Function > > CryptoEasyErr: > Debug.Assert False > 'Resume > Resume CryptoEasyExit > > End Function 'CryptoEasy > I suspect that it does not work with RTF files due to the limitation to ascii values between 32 and 127 (i.e. the basic printable ascii 7 bit charset). Try quoting out the if...endif block. |