Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need help with converting from ASCII to HEX on VB 2010
#1
Hello, to start off I really don't know how I can setup the scripting for the program.

I do have an example website on how I want my program to work, but I am only wanting to borrow certain features from it:

<!-- m --><a class="postlink" href="http://mikezilla.com/exp0012.html">http://mikezilla.com/exp0012.html</a><!-- m -->

What parts I want to add to my program is:

-Taking the ASCII Text with the encode button
-Have the Hex text box (Without the decode button)

I honestly have tried to do this but I got confused and failed at it. Help is much appreciated.
#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...
#3
Thank you so much for your help. I have been curious on how to do this for months.
#4
Oh wow, there is an actual Conversion class? Wow! You learn something new everyday, eh? Thanks a lot for your response, Snake_eyes!
My Blog | My Setup | My Videos | Have a wonderful day.


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

Forum Jump:


Users browsing this thread: 1 Guest(s)