Jump to content
Xtreme .Net Talk

VB.NET equivelent of chr$() and asc() ?


Recommended Posts

Guest JustAProg
Posted

Like the various uses of 'myString.substring' are used in vb.net instead of the old vb6 left, right and mid. Can someone tell me the vb.net version of, for example: chr$(34) and asc("Z"), thanks.

 

I don't want to use the above, or bring in the vb namespace, I'd like to find the proper vb.net way of doing them.

 

Thanks

  • *Gurus*
Posted

Not sure if this is really any faster, but you can use the native

System.Convert class.

System.Windows.Forms.MessageBox.Show(System.Convert.ToChar(34)) 'Chr$(34)
System.Windows.Forms.MessageBox.Show(System.Convert.ToByte("Z"c)) 'Asc("Z")

Guest JustAProg
Posted

Thank you. That's exactly what I was after, cheers.

 

By the way, what's the 'little c' for, I thought it was a typo to start with then realised it's needed, seems rather out of place if ya know what I mean.

 

>> ("Z"c) <<

  • *Experts*
Posted

The little c represents that the value in quote marks is a Char,

not a String, so you can tell the difference when debugging. The

ToChar method, as the name implies, returns a Char, not a String

like Chr$() does.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...