Visual Basic Codes
ActiveX
Miscellaneous
Applications
Code Snippets
Common Dialogs
Special Effects
Database Stuff
Date Time
Files Drives
Forms
Graphics Games
Internet Stuff
Multimedia
Other
Strings
Windows
Visual Basic > Applications-VBA sample source codes
(De)Coding Ascii
(De)Coding Ascii BTW, here's a little doo-dad that I threw together that moves the ascii value of each character up (encode) or down (decode), with a default change of 40. So, for example, chr(233) might become chr(21), or chr(74) might become chr(114). Anyone who knows what they're doing could easily decode it, but at least it's not legible if you open the file in Notepad, etc. Try it! Syntax is: encode(mytext, [range]) and decode(mytext, [range]). Public Function Encode(Data as String, Optional Depth as Integer) as String Dim TempChar as String Dim TempAsc as Integer Dim NewData as String Dim vChar as Integer For vChar = 1 To Len(Data) TempChar = Mid$(Data, vChar, 1) TempAsc = Asc(TempChar) If Depth = 0 Then Depth = 40 'DEFAULT DEPTH If Depth > 254 Then Depth = 254 TempAsc = TempAsc + Depth If TempAsc > 255 Then TempAsc = TempAsc - 255 TempChar = Chr(TempAsc) NewData = NewData & TempChar Next vChar Encode = NewData End Function Public Function Decode(Data as String, Optional Depth as Integer) as String Dim TempChar as String Dim TempAsc as Integer Dim NewData as String Dim vChar as Integer For vChar = 1 To Len(Data) TempChar = Mid$(Data, vChar, 1) TempAsc = Asc(TempChar) If Depth = 0 Then Depth = 40 'DEFAULT DEPTH If Depth > 254 Then Depth = 254 TempAsc = TempAsc - Depth If TempAsc < 0 Then TempAsc = TempAsc + 255 TempChar = Chr(TempAsc) NewData = NewData & TempChar Next vChar Decode = NewData End Function Return
Privacy Policy
|
Link to Us
|
Links