Results 1 to 5 of 5

Thread: Loop without Do error

  1. #1
    Guest

    Post

    I've got this simple Do While Not..Loop structure that should work. It doesn't, and returns an error that there is a 'Loop without Do' - if I remove the loop line I get a 'Do without Loop' error.

    This is exactly the same if I try a For..While..Next structure as well.

    Can someone please help me out of this paradox!!

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670

    Post

    A Do loop has the following syntax;

    Do {While | Until} condition
    [statements]
    [statements]
    Loop

    or

    Do
    [statements]
    [statements]
    Loop {While | Until} condition


    A While..Wend loop has the following syntax;

    While condition
    [statements]
    Wend


    If this helps..



    ------------------
    Mark "Buzby" Beeton
    VB Developer
    [email protected]



  3. #3
    Guest

    Post

    Here's my exact code:

    If remvar = 3 Then
    i = 0
    b = 0

    Do While Not b = c

    Do While Not i = 6

    'Do stuff with i

    i = i + 1
    Loop

    b = b + 1
    i = 0
    Loop
    End If

    Its the inner Do...Loop that returns the error first - if I remove that loop the other one returns the error.

    A few lines above, in the same procedure, there is a almost identical Do...Loop structure that doesn't return any errors...

    Has anyone heard of this happening before?

    Mafro still

  4. #4
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670

    Post

    Have you tried it with

    Do While i<>6
    and
    Do While b<>c

    ?

    this may help.



    ------------------
    Mark "Buzby" Beeton
    VB Developer
    [email protected]



  5. #5
    Guest

    Post

    I worked it out! I had a If loop within the middle Do loop which was missing its End If at the end.

    This was causing VB to think there was an extra 'Loop' inside the If loop where it wasn't needed...

    Thanks for trying!
    I'll read my code harder next time!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width