0

I have a loop to look for the key i.d. "veh2." The loop is there because even though the next line in the text file is where it should be, it is not there in all cases. The problem I'm having as far as wording or a way to go about it is what if instead there is the key i.d. "veh1?

Do While (line_text.Substring(0, 4).ToString <> "VEH2")
          line_text = myreader.ReadLine
Do While line_text.Length < 3
         line_text = myreader.ReadLine()
Loop
     Loop

How do I go about forgetting to search for VEH2 and instead deal with the text after VEH1 (if it is in fact there)?

Edited by Gus_19

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by Gus_19
0

I'm trying to figure out how I can wrap a conditional 'IF' statement within the loop to say if the substring is equal to VEH1, then 'do this.' Otherwise, if the substring is equal to VEH2 than 'do that.' No matter how I put the statement, I keep getting a null exception error. Hope this helps. I can put in more of my code if needed too.

0

Did you try this?

Do While (line_text.Substring(0, 4)ToString <> "VEH2") Or (line_text.Substring(0, 4)ToString <> "VEH1")
    line_text = myreader.ReadLine
    If (line_text.Substring(0, 4)ToString <> "VEH1") then
        Do While line_text.Length < 3
            line_text =  myreader.ReadLine()
        Loop
    Else
        Do While line_text.Length < 3
            line_text =  myreader.ReadLine()
        Loop
    Endif
Loop

Edited by Reverend Jim: fixed formatting

0

Thank you. It was just a simple, not wrapping the if statement in the correct location.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.