Results 1 to 6 of 6

Thread: While....Wend

  1. #1

    Thread Starter
    Hyperactive Member WP's Avatar
    Join Date
    Aug 2000
    Location
    Belgium
    Posts
    278

    Post

    Whats the difference between these?

    Code:
    (1)
    While a > 1
    ...
    Wend
    (2)
    Do While a > 1
    ...
    Loop
    WP

    Visual Basic 6.0 EE SP5 / .Net
    Windows XP

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    None!
    The Do loop can be written like this:
    Code:
    Do While a > 1
    '...
    Loop
    'or like this
    Do Until a > 1
    '...
    Loop
    'or you can put the While|Until part at the end
    Do
    '...
    Loop While a > 1
    
    Do 
    '...
    Loop Until a > 1
    But using the first Do loop is the same as doing the While ... WEnd loop.
    The reason for having two syntaxes that do the same thing is because the older While ... WEnd loop is an inheritance from older BASIC versions like QBasic.

  3. #3
    Fanatic Member
    Join Date
    Apr 2000
    Location
    Whats a location?
    Posts
    516
    The guy who wrote a VB Book I've got says that you should always use Do...Loop because it is more flexible.

    Courgettes.

  4. #4
    Fanatic Member Mad Compie's Avatar
    Join Date
    Aug 2000
    Location
    Kuurne (Belgium)
    Posts
    553
    The Do..Loop iteration type gives you more possibilities to the wanted loop.
    The While statement is yes indeed an inheritance of older BASIC versions.
    Please note that pseudo-code also uses Do..Loop to explain an iteration process instead of the While notation, because of it's readibility.

  5. #5
    Guest
    Do...Loop is more flexible than Wend. For example, you can replace While with Until and you have the ability to exit the loop by using a simple Exit Do statement.

  6. #6

    Thread Starter
    Hyperactive Member WP's Avatar
    Join Date
    Aug 2000
    Location
    Belgium
    Posts
    278

    Wink Thanks

    Thanks all of you a lot

    WP

    Visual Basic 6.0 EE SP5 / .Net
    Windows XP

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