Hi,
I am reading lines from a text file.
80+15
90-12
etc.
For each line I am extracting two integers.
From the first line,
CLn will be 80
CLa will be 95
From the second line,
CLn will be 90
CLa will be 78
I got it working like this
arrLine(10).Trim is the dynamic text that can be num1+num2 or num1-num2
VB Code:
Dim cl As String = arrLine(10).Trim Dim clN As Integer = 0 Dim clA As Integer = 0 Dim arr As String() = cl.Split("+") clN = arr(0).Split("-")(0) clA = clN If arr.Length > 1 Then clA = clN + arr(1) Else arr = cl.Split("-") If arr.Length > 1 Then clA = clN - arr(1) End If End If Console.WriteLine (cl.ToString & " is " & clN.ToString & " and " & cla.ToString)
I find this "overcomplicating" a simple task and would like to ask how to do it more effectively may be using some .NET functions I am unaware of.
Thanks,
McoreD




Reply With Quote