textbox question the lines

RonR

Well-known member
Joined
Nov 23, 2007
Messages
82
Programming Experience
5-10
I need to extract the lines of text in a textbox one at a time while omitting lines that are blank.
 
VB.NET:
Dim str As String
For Each str In TextBox1.Lines
     If str <> "" Then
        Debug.Print(str)
     End If
Next
 
VB.NET:
Dim str As String
For Each str In TextBox1.Lines
     If str.Trim.Length > 0 Then
        Debug.Print(str)
     End If
Next
 
oops!!!


I have a problem.



str gives me this error:


Error 1 Loop control variable cannot be a property or a late-bound indexed array.


it worked in one sub but I cannot get it to work in any others.


what is happening????
 
VB.NET:
Dim str As String
For Each str In TextBox1.Lines
     If str.Trim.Length > 0 Then
        Debug.Print(str)
     End If
Next


I have tried changing the srt but it still gives me trouble. it will not accept
any variable.

also, str is an internal command so that one may create a conflict anyway.
 
str is now an internal command? This must be new cause in VS 2005 and all versions of vb older than 2005, it's not.

Try this:
VB.NET:
Dim MyString() As String = Textbox1.Lines
For Each CurrentLine As String in MyString
  If CurrentLine.Trim.Length > 0 Then
    'Your Code Here
  End If
Next
 
I have been using str to turn a number into a string.(I think).


ok. I will try your new code.

thanks!!! I will let you know.
 

Latest posts

Back
Top