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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String.fromCharCode(97,98,99) VB Equivelent? 2

Status
Not open for further replies.

mattscotney

Programmer
Jul 31, 2002
57
AU
In javascript there is a static method for converting ASCII code to characters. An example is: String.fromCharCode(97,98,99) which will produce the string "abc".

How do I do exactly the same thing in visual basic?

Thanks for your help,
Matt Scotney
 
That works ok to a point but not with special characters.

When you use Chr$(286) it does not work.

When using the same with javascript:
String.fromCharCode(286) you get the character: Ð

How do I make the VB code do the same?

Thanks for your help,
Matt Scotney
 
Standard ASCII characters fall in the range 0 to 255.
CHR only supports single byte characters.

If you are using a DBCS (which you must be to have characters above 255) you can use ChrW instead. Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Thanks John the ChrW fixed the character problem.

Also if anyone could you tell me the VB equivelent to the javascript: x = y.charCodeAt(i)

Thanks in advance,
Matt Scotney
 
x = ASC(MID(Y,i,1))
but agian this is ascii only if you need double byte char data back use AscW()
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top