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:
  1. Dim cl As String = arrLine(10).Trim
  2. Dim clN As Integer = 0
  3. Dim clA As Integer = 0
  4.  
  5. Dim arr As String() = cl.Split("+")
  6. clN = arr(0).Split("-")(0)
  7. clA = clN
  8.  
  9. If arr.Length > 1 Then
  10.     clA = clN +  arr(1)
  11. Else
  12.     arr = cl.Split("-")
  13.     If arr.Length > 1 Then
  14.         clA = clN - arr(1)
  15.     End If
  16. End If
  17.  
  18. 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