londonkiwi
Programmer
I'm reading a string from a text file - whats wrong with the if-then-else staement?? Thanks in anticipation
Do Until EOF(FileNumRead) ' get first line of data
Line Input #FileNumRead, sLine
Do While Left(sLine, 2) >= 12 And Left(sLine, 2) <= 18 'time btw 12-18 hrs
If Mid(sLine, 19, 1) = 1 Then ' AtoB
If Trim(Mid(sLine, 21, 2)) = 1 Then 'Class = 1
ab1_Count = ab1_Count + 1
ElseIf Trim(Mid(sLine, 21, 2)) = 2 Then 'Class = 2
ab2_Count = ab2_Count + 1
End If
ElseIf Trim(Mid(sLine, 21, 2)) = 3 Then 'Class = 3
ab3_Count = ab3_Count + 1
End If
ElseIf Trim(Mid(sLine, 21, 2)) = 4 Then 'Class = 4
ab4_Count = ab4_Count + 1
End If
ElseIf Trim(Mid(sLine, 21, 2)) = 5 Then 'Class = 5
ab5_Count = ab5_Count + 1
End If
Else: Trim(Mid(sLine, 21, 2)) = 6 'Class = 6
ab6_Count = ab6_Count + 1
End If
End If
End If
Loop
Loop
Print #FileNumWrite, ab1_Count & " " & ab2_Count & " " & ab3_Count & " " & ab4_Count & ab5_Count & "12-18" [sig][/sig]
Do Until EOF(FileNumRead) ' get first line of data
Line Input #FileNumRead, sLine
Do While Left(sLine, 2) >= 12 And Left(sLine, 2) <= 18 'time btw 12-18 hrs
If Mid(sLine, 19, 1) = 1 Then ' AtoB
If Trim(Mid(sLine, 21, 2)) = 1 Then 'Class = 1
ab1_Count = ab1_Count + 1
ElseIf Trim(Mid(sLine, 21, 2)) = 2 Then 'Class = 2
ab2_Count = ab2_Count + 1
End If
ElseIf Trim(Mid(sLine, 21, 2)) = 3 Then 'Class = 3
ab3_Count = ab3_Count + 1
End If
ElseIf Trim(Mid(sLine, 21, 2)) = 4 Then 'Class = 4
ab4_Count = ab4_Count + 1
End If
ElseIf Trim(Mid(sLine, 21, 2)) = 5 Then 'Class = 5
ab5_Count = ab5_Count + 1
End If
Else: Trim(Mid(sLine, 21, 2)) = 6 'Class = 6
ab6_Count = ab6_Count + 1
End If
End If
End If
Loop
Loop
Print #FileNumWrite, ab1_Count & " " & ab2_Count & " " & ab3_Count & " " & ab4_Count & ab5_Count & "12-18" [sig][/sig]