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

Convert character to Ascii without ASC

Status
Not open for further replies.

kenbw

Programmer
May 2, 2002
39
US
Everyone,
Yes I'm sure using the ASC function that is part of the Visual Basic runtime environment left over from VB6 would be the easiest way to do this, but I don't want to use it. I want to find a better way, mainly because I want to be able to build using Nant and seem to be having some problems with that when I'm trying to use some of the older VB functions such as Mid, Trim, LTrim, etc. Right now all I'm trying to do is take a single character and get its ascii equivalent.

Thanks in advance,
Ken
 
This works even though their is no documented method for Char rather than Char() in GetBytes.

Option Strict On
Dim x As Char = "a"c
Dim bytw() As Byte
Dim encAsc As New System.Text.ASCIIEncoding()
bytw = encAsc.GetBytes(x) ' = 97


Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top