Support Forums

Full Version: Loop through textbox
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
VB section is falling asleep. So I thought I'd post this simple code. I did a search and didnt find anything already so here it is.


This code will loop through each line of a textbox. This is useful if you want to number the lines or something of that nature.
Code:
For Each line As String In TextBox1.Lines
    MessageBox.Show(line)
  Next

I used to split the texbox like this, but the code above seems to work better.
Code:
Dim str As String() = TextBox1.Text.Split(Environment.NewLine)
  For Each s As String In str
    MessageBox.Show(s)
  Next