Results 1 to 5 of 5

Thread: Loop Forever

  1. #1
    Join Date
    Sep 2005
    Posts
    313

    Unanswered: Loop Forever

    In MS Access,
    in VBA,

    How do I make loop forever?
    No condition

    Do while ///

    ...
    loop

    I don't need condition to stop the while loop, but when I use it, the program force me to write the condition (stop), so how can I skip?

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Use
    Do While 1=1


    Loop

    i.e

    Do While True


    Loop

    to make an endless loop


    But you have to design your condition so that you will be able to leave the loop

  3. #3
    Join Date
    Nov 2003
    Posts
    1,487
    Do
    '....code....
    '....code....
    Loop

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  4. #4
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    If you want that the program asks you whether to leave the loop or not you can do something like that

    PHP Code:
    Dim Qu as string
    Qu
    "Start"

    Do While Qu "Start"
      
    put your code here
      put your code here
      put your code here

      Qu 
    =  InputBox("Type Stop to quit""continue looping ")
    Loop 
    If the user types Stop the loop will be exit

    Note, every iteration of the loop the user will be asked the same question....

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I'd suggest you put a "do events" into your loop to allow other processes some time on the cpu

    Follwoing on from Hambakka's suggestion an alternative is to loop untill a control on the form has soemhing

    eg
    mycontrol.value=vbnull
    while mycontrol.value=vbnull
    do events
    wend

    btw permanent loops are rarely a 'good' idea, how are you proposing to stop the process?

Posting Permissions

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