459,259 Members | 1,690 Online
Need help? Post your question and get tips & solutions from a community of 459,259 IT Pros & Developers. It's quick & easy.

# Decode ASCII

 P: 6 i used a code to decode a ASCII code: Expand|Select|Wrap|Line Numbers textbox1.text=chr(textbox2.text) when i type 97 in textbox2, textbox1 show correct answer that is 'a'. But when i type 9797, is there any possible ways to get 'aa' in textbox1? Apr 18 '10 #1
4 Replies

 100+ P: 320 hmm well If that is all you want to do then a crude way of doing it is like this Expand|Select|Wrap|Line Numbers           Dim t1, t2 As String         If TextBox2.Text.Length = 4 Then             t1 = Chr(TextBox2.Text.Substring(0, 2))             t2 = Chr(TextBox2.Text.Substring(2, 2))         Else             t1 = Chr(TextBox2.Text)             t2 = ""         End If         TextBox1.Text = t1 & t2   however it's not very practical because it assumes that the only two scenarios will be either a case of 1) two chars - both a two character ASCII, or 2) a single char with one or two ASCII characters. if you could explain more comprehensively what you are trying to do, we may be able to help with a better solution. Apr 18 '10 #2

 Expert 2.5K+ P: 3,525 just do a loop... for the length of the textbox.text... get the next character... make the ascii... add it to the output... continue loop Apr 18 '10 #3

 P: 6 @yarbrough40 actually what i want to do is I try to parse a few information in my system into ASCII and put it into database to secure it. After that, i can redeem it into my system again and use it. Apr 18 '10 #4

 P: 6 @lauclaw thank you all and i found my way Expand|Select|Wrap|Line Numbers Dim i As Integer = 0         Dim l As Integer = Me.TextBox2.Text.Length         Dim a As String = Nothing         While i < l             If Me.TextBox2.Text.Substring(i, 2) > 31 And Me.TextBox2.Text.Substring(i, 2) < 130 Then                 a += Chr(TextBox2.Text.Substring(i, 2))                 i += 2             Else                 a += Chr(TextBox2.Text.Substring(i, 3))                 i += 3             End If         End While         Me.TextBox3.Text = a Apr 18 '10 #5