Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21271

[RESOLVED] String -> hex string -> string problem with vbCrLf

$
0
0
:) Hello,
I am writing a note program, and it saves the note contents into a file.
I use these 2 subs (ECString to convert the string to hex string and DCString to convert it back into a human readable string).

Code:

Private Function ECString(Expression As String) As String
    Dim endstring As String
    For i = 1 To Len(Expression)
        endstring = endstring & Hex(Asc(Mid(Expression, i, 1)))
    Next i
    ECString = endstring
End Function

Private Function DCString(Expression As String) As String
    Dim endstring As String
    For i = 1 To Len(Expression) - 1 Step 2
        endstring = endstring & Chr(Val("&H" & Mid(Expression, i, 2)))
    Next i
    DCString = endstring
End Function

It goes wrong when I use a newline character, because it then puts 2 Ú characters (ascii #218).

Now I know I'm doing something wrong here, but I don't know what...?

Viewing all articles
Browse latest Browse all 21271

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>