loops/counters

ARC

Well-known member
Joined
Sep 9, 2006
Messages
63
Location
Minnesota
Programming Experience
Beginner
Could anyone offer a hint at what I'm doing wrong? This only spits out the first letter ascii value then stops.

VB.NET:
[SIZE=2]counter = 1[/SIZE][SIZE=2]
encodeme = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].TextBox1.Text
codedTextBox2 = [/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].TextBox2.Text
[/SIZE][SIZE=2][COLOR=#0000ff]Do
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'grabs (Counter) letter from the string in TextBox1
[/COLOR][/SIZE][SIZE=2]letter = Microsoft.VisualBasic.Mid(encodeme, counter, 1)
[/SIZE][SIZE=2][COLOR=#008000]'changes "letter" into uppercase
[/COLOR][/SIZE][SIZE=2]coded = UCase(letter)
[/SIZE][SIZE=2][COLOR=#008000]'changes coded into ascii value
[/COLOR][/SIZE][SIZE=2]newcoded = Asc(coded)
[/SIZE][SIZE=2][COLOR=#008000]'adds the ascii'd letter to the end of whatever is in TextBox2
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Me[/COLOR][/SIZE][SIZE=2].TextBox2.Text = codedTextBox2 + newcoded
counter = counter + 1
 
[/SIZE][SIZE=2][COLOR=#0000ff]Loop[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Until[/COLOR][/SIZE][SIZE=2] counter > 4
[/SIZE]

I tried doing it like "do until counter > 4" and also "do while counter < 4" and neither of those worked either. Same result. I figured i would try the above ("do loop until loop"). Nothing.

I want it to run until all the text in the text box is converted to anscii but I wanted to make sure I was using the loop properly first so im trying this.

Any hints or suggestions would be greatly appreciated!
 
VB.NET:
Dim encodeme As String = TextBox1.Text
Dim encoded As String = ""
For Each c As Char In encodeme.ToUpper.ToCharArray
  encoded &= Asc(c)[SIZE=2].ToString
[/SIZE]Next
TextBox1.Text = encoded
 
easy:
VB.NET:
        Dim decodeme As String = TextBox1.Text
        Dim decoded As String = ""
        For i As Integer = 0 To decodeme.Length - 2 Step 2
            decoded &= Chr(CInt(decodeme.Substring(i, 2)))
        Next
        TextBox1.Text = decoded
 
Back
Top