Results 1 to 4 of 4

Thread: wend vs loop

  1. #1

    Thread Starter
    Lively Member Cerebrate's Avatar
    Join Date
    May 2000
    Posts
    82

    Question

    for the "while" loop, what's the difference between "wend" and "loop", what's the function of them????
    I am so confused.


    Cerebrate

  2. #2
    Guest

    Thumbs up

    The Do...Loop is provides a more structured and flexible way of looping, for example, the Do Loop you can use While or Until and you can use the Exit Do function to exit the Loop.

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    The While ... Wend loop was maintained for backwards-compatibility with older versions of Basic. QBasic introduced Do While ... Loop as a replacement, and was carried over to VB. As Megatron said, "Do" is more flexible in that you can also use "Until" with it and you can use "Exit Do" to get out of it. Essentially though, the following two examples are equivalent:

    Do While x <= 10
    Debug.Print x
    x = x + 1
    Loop

    While x <= 10
    Debug.Print x
    x = x + 1
    Wend

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Some more goodies about Do loop
    [code]
    1.
    Do while condition1
    Loop
    'Is the same as
    Do until not condition1
    Loop
    2.
    Do
    Loop while condition2
    'Is the same as
    Do
    Loop until not condition2
    [code]
    And for 1. you will skip the loop whenever the condition is true
    And for 2. you will exit the loop after the code been executed in it, if the condition is true
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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