Results 1 to 6 of 6

Thread: Do While vs. Do until

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 1999
    Location
    Los Angeles
    Posts
    186

    Talking

    Hey guys, I have somewhere read the we shouldn't use
    Do While but Do Until,

    Did you know that? do you know why?

    André

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    I haven't heard that, as both constructs are useful depending on what you want to do. Maybe you read that we should shy away from the "While/Wend" construct because it only remains in the language for backwards compatibility and has been replaced by "Do While/Loop".
    "It's cold gin time again ..."

    Check out my website here.

  3. #3
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    DO UNTIL means that you want it to do something until something else happens i.e.

    Code:
    Do
    Progressbar1.value = Progressbar1.value + 1
    Loop Until ProgressBar1.value = 100
    that code will keep adding a 1 to the progress bar wuntil it reaches 100

    DO WHILE means that you want it to do someting while something else is happening i.e.

    Code:
    Do
    Progressbar1.value = Progressbar1.value + 1
    Loop While ProgressBar1.value = 100
    that will add a 1 to the progress bar only if the value of the progress bar is 100


    I hope that you understand this

    [Edited by dimava on 09-19-2000 at 06:55 AM]
    NXSupport - Your one-stop source for computer help

  4. #4
    Guest
    I usually use Do Until.

    Code:
    Do Until Progressbar1.Value = 100
    Progressbar1.Value = Progressbar1.Value + 1
    DoEvents
    Loop
    You could also use the For..Next statement as well.

    Code:
    For i = 0 to 100
    Progressbar1.Value = i
    DoEvents
    Next i

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 1999
    Location
    Los Angeles
    Posts
    186
    Thanks, I know all of these constructions, the thing is that Bruce is close to what I read. It's an old construct to be fased out.

    Thanks guys, have a great day!

    André

  6. #6
    Guest
    When dealing with larger loops, using a For...Next loop is much faster than a Do...While loop.

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