CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Location
    .NET2.0 / VS2005 Developer
    Posts
    7,104

    How to write a while loop in VB ?

    i see these:

    Code:
    Do While <condition>
      'code
    Loop
    
    
    Do
      'code
    Loop While <condition>
    
    
    Do Until <condition>
      'code
    Loop
    
    
    Do
      'code
    Loop Until <condition>
    
    
    While <condition>
      'code
    Wend
    
    
    While <condition>
      'code
    End While
    note.. this is from memory so some things might be the wrong way round.. can someone tell me what is the form of a while loop? at the moment i do While/Wend but if this is old style (like saying Call <function>) then i'll switch.. just need an authoritative statement

    cheers
    "it's a fax from your dog, Mr Dansworth. It looks like your cat" - Gary Larson...DW1: Data Walkthroughs 1.1...DW2: Data Walkthroughs 2.0...DDS: The DataSet Designer Surface...ANO: ADO.NET2 Orientation...DAN: Deeper ADO.NET...DNU...PQ

  2. #2
    Join Date
    Oct 2001
    Location
    Melbourne, Australia
    Posts
    576

    Re: How to write a while loop in VB ?

    while/wend isn't valid in vb.net, but the ide (visual studio 2003 at least) auto-converts it to End While. but you probably already knew that

  3. #3
    Join Date
    Dec 2001
    Posts
    6,332

    Re: How to write a while loop in VB ?

    There is no single "correct" way to do it. It just depends on what you need.
    Please remember to rate the posts and threads that you find useful.
    How can something be both new and improved at the same time?

  4. #4
    Join Date
    Sep 2001
    Location
    Québec, Canada
    Posts
    1,923

    Re: How to write a while loop in VB ?

    They are all equivalent, only, you can't do Exit Do (or Exit While) in a while wend loop, so I believe it make it easier to read and understand as there is only one condition to exit.

    JeffB
    CodeGuru VB FAQ Visual Basic Frequently Asked Questions
    VB Code color Tool to color your VB code on CodeGuru
    Before you post Importants informations to know before posting

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

Featured