[RESOLVED] Read char from end of string?
So, my code is as below; I can't understand where my mistake is for the code not to work with "i" going backwards, or maybe it isn't supposed to work like that and there's another way round it (it works in c++). Code's inside a button.
EDIT: NVM, I found it, it was pretty simple, add "step - 1" after the 0.
vb Code:
Dim counter As Integer = 0
' RichTextBox1.Text = RichTextBox1.Text.Replace(" ", "")
' RichTextBox1.Text = RichTextBox1.Text.Replace(".", "")
' RichTextBox1.Text = RichTextBox1.Text.Replace(vbLf, "")
' Dim j As Integer ' = RichTextBox1.Text.Length
'For i = 0 To RichTextBox1.Text.Length - 1
For i = (RichTextBox1.Text.Length - 1) To 0 ' This one doesn't work
MsgBox(RichTextBox1.Text.Chars(i))
' Exit For
Next
For i = 0 To (RichTextBox1.Text.Length - 1) ' This one works
MsgBox(RichTextBox1.Text.Chars(i))
' Exit For
Next
' Next