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 4 Years Ago by Gus_19

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.

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 4 Years Ago by Reverend Jim: fixed formatting

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

This article has been dead for over six months. Start a new discussion instead.