Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need help with converting from ASCII to HEX on VB 2010
#2
First of all in the programing language the conversion is called "from string to hexadecimal" and it is real easy to achive as the folowing code snippet will demonstrate.

Just create a new project and add two textboxes and a button. Then add the function below in your main class:

[code2=vbnet]Public Function StrToHex(ByRef Data As String) As String
Dim sVal As String
Dim sHex As String = ""
While Data.Length > 0
sVal = Conversion.Hex(Strings.Asc(Data.Substring(0, 1).ToString()))
Data = Data.Substring(1, Data.Length - 1)
sHex = sHex & sVal
End While
Return sHex
End Function[/code2]

Next double click the button and call the function:

[code2=vbnet]Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox2.Text = StrToHex(TextBox1.Text)
End Sub[/code2]
... and that should be all.

Now if you want to show the % sign just like the web site modify this line
[code2=vbnet]sHex = sHex & sVal[/code2]
with this one
[code2=vbnet]sHex = sHex & "%" & sVal[/code2]
Sssssssssoftware developer...


Messages In This Thread
Re: I need help with converting from ASCII to HEX on VB 2010 - by Snake_eyes - 03-14-2013, 01:55 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  VB 2008 VS vb 2010 Emerogork 5 22,577 11-14-2013, 02:19 PM
Last Post: brandonio21
  Visual Studio 2010 Professional LearningComputer 2 12,546 03-11-2012, 03:29 PM
Last Post: brandonio21

Forum Jump:


Users browsing this thread: 1 Guest(s)