I need help with converting from ASCII to HEX on VB 2010 - Printable Version +- BP Forums (https://bpforums.info) +-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55) +--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56) +---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8) +---- Thread: I need help with converting from ASCII to HEX on VB 2010 (/showthread.php?tid=757) |
I need help with converting from ASCII to HEX on VB 2010 - Somebody<3 - 03-10-2013 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. Re: I need help with converting from ASCII to HEX on VB 2010 - Snake_eyes - 03-14-2013 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] Re: I need help with converting from ASCII to HEX on VB 2010 - Somebody<3 - 03-14-2013 Thank you so much for your help. I have been curious on how to do this for months. Re: I need help with converting from ASCII to HEX on VB 2010 - brandonio21 - 03-24-2013 Oh wow, there is an actual Conversion class? Wow! You learn something new everyday, eh? Thanks a lot for your response, Snake_eyes! |