XSYLUS
Member
- Joined
- Jan 25, 2008
- Messages
- 5
- Programming Experience
- Beginner
Greetings!
Okay, here's the deal, I've been working on a program for the past week (in my spare time) and I've gotten pretty far on my own with the help of several ebooks and a few google searches. But now I'm stuck on what might be a very simple problem.
I have an if statement which checks the values of each line of a multiline textbox for the first value that is a positive number.
Example:
Let's say there are 5 lines in the textbox, the if statement (which is nested inside of a For/Next loop) checks each line and stops the loop as soon as a positive value is found.
Thus:
-22
-8
10
32
58
Displays 10 in the output field, which is exactly what I wanted, however, what I also need is for the output field to display which line that number is found on. In this case it's on line 3.
I know that the values in the textbox make up an array but I can't quite figure how to get it to output the line number.
Would I use Ubound, and if so how?
Here's the exact code I'm using, to help avoid too much confusion.
Okay, here's the deal, I've been working on a program for the past week (in my spare time) and I've gotten pretty far on my own with the help of several ebooks and a few google searches. But now I'm stuck on what might be a very simple problem.
I have an if statement which checks the values of each line of a multiline textbox for the first value that is a positive number.
Example:
Let's say there are 5 lines in the textbox, the if statement (which is nested inside of a For/Next loop) checks each line and stops the loop as soon as a positive value is found.
Thus:
-22
-8
10
32
58
Displays 10 in the output field, which is exactly what I wanted, however, what I also need is for the output field to display which line that number is found on. In this case it's on line 3.
I know that the values in the textbox make up an array but I can't quite figure how to get it to output the line number.
Would I use Ubound, and if so how?
Here's the exact code I'm using, to help avoid too much confusion.
VB.NET:
1.) For Each line As String In Me.txtBox4.Lines
2.) Decimal.TryParse(line, System.Globalization.NumberStyles.Any, Nothing, value1)
3.) If value1 >= 1 Then
4.) lblOutput.Text = value1
5.) Exit For
6.) End If
7.) Next