Results 1 to 1 of 1

Thread: [RESOLVED] Read char from end of string?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2010
    Posts
    131

    Resolved [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:
    1. Dim counter As Integer = 0
    2.  
    3.     '    RichTextBox1.Text = RichTextBox1.Text.Replace(" ", "")
    4.     '   RichTextBox1.Text = RichTextBox1.Text.Replace(".", "")
    5.     '  RichTextBox1.Text = RichTextBox1.Text.Replace(vbLf, "")
    6.  
    7.     '    Dim j As Integer ' = RichTextBox1.Text.Length
    8.  
    9.         'For i = 0 To RichTextBox1.Text.Length - 1
    10.  
    11.         For i = (RichTextBox1.Text.Length - 1) To 0 ' This one doesn't work
    12.             MsgBox(RichTextBox1.Text.Chars(i))
    13.             ' Exit For
    14.         Next
    15.  
    16.         For i = 0 To (RichTextBox1.Text.Length - 1) ' This one works
    17.             MsgBox(RichTextBox1.Text.Chars(i))
    18.             ' Exit For
    19.         Next
    20.  
    21.  
    22.  
    23.  
    24.  
    25.         ' Next
    Last edited by Legjendat; Apr 3rd, 2012 at 09:19 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width