changing characters

sg225551

New member
Joined
Mar 12, 2008
Messages
3
Programming Experience
Beginner
hi

I have a string and i would like to change each character in the string to another character.

For example, from "password" i then increase by 2 postion of each character to "rcuuyqtf".
 
I would use a For Each loop to loop through the Chars in the String. For each character you'll want to apply the transformation and then add the result to a new String. You can just use two arrays of Chars to provide the transformation. There are other ways to do it but that's probably the easiest.
 
hi

Thanks but i am stuck here.

For i As Integer = 0 To strOriginal.Length - 1
strApp.Append(strOriginal(i.ToString))
Next i
TextBox2.Text = strApp.ToString
 
The first thing to note is that I said this:
I would use a For Each loop to loop through the Chars in the String.
and I don't see any For Each loop in your code.

That said, you can use a For loop and get the Chars from the String by index, but you get them by a NUMERICAL index. You've already got the index and you're converting it to a String. No. Use the number, not a string representation of the number.
 
Back
Top