Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Looping through a string for ASCII convert

Status
Not open for further replies.

cfsponge

Programmer
Feb 22, 2006
44
US
I am trying to come up with a simple loop that takes each character from a string and converts it to its ASCII equivalent. I tried using split(), but since there is no delimiter that's no good.

I would output a string from a database field, and convert it to { (example) but it would still render correctly when viewing it in a browser window.
 
Have a look at the For ... Next instruction and at the Len, Mid and Asc functions.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Try something like this:
Code:
Dim oldstring, newstring

'get string to be converted

Dim oi, onechar

newstring = ""

For oi = 1 To Len(oldstring)
  onechar = Mid(oldstring, oi, 1)
  newstring = newstring & "&#" & Asc(onechar) & ";"
Next

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top