0

Will this cause any problems?

iCarli = 1

Do While .SelectSingleNode("//ROWSET/ROW/VENDORPARTNUM" & CStr(iCarli)).Text <> EMPTY_STRING

    'Statements here for setting up array and its assignment

    iCarli = iCarli + 1

Loop Until iCarli = 10

The point here being that I need to use the two conditions, node is not empty and the counter cannot exceed 9 without throwing some unforeseen error. (I know that I could use the If iCarli = 10 Then Exit Do).

Thoughts?

Thanks

1
  • Never mind. The answer is no. Compiling it throws a syntax error. Commented Feb 27, 2015 at 23:33

1 Answer 1

1

Yes that will cause problems. The IDE will not accept it as valid syntax. You can either Do While/Until or Loop While/Until, but not both. But you can just put in a test at the bottom of the loop to exit:

Sub WillNotWork()
    Dim i As Long
    i = 1&
    Do While i > 1&

        i = i + 1&

    Loop Until i > 10&
End Sub

Sub InsteadUse()
    Dim i As Long
    i = 1&
    Do While i > 1&
        i = i + 1&
        If i > 10& Then
            Exit Do
        End If
    Loop
End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.