Reputation: 33
I am trying to write a function using Excel VBA to convert a string to its respective ASCII number. For example:
"ABCD" => "65666768"
I have written this code but it's failed to do the conversion:
Public Function asciien(s As String) As String
' Returns the string to its respective ascii numbers
Dim i As Integer
For i = 1 To Len(s)
asciien = asciien & CStr(Asc(Mid(s, x, 1)))
Next i
End Function
Upvotes: 2
Views: 19917
Reputation: 580
This line
asciien = asciien & CStr(Asc(Mid(s, x, 1)))
should read
asciien = asciien & CStr(Asc(Mid(s, i, 1)))
"x" has no value
Upvotes: 3