Flow Control Statements

Team-Fly    

 
Visual Basic .NET Unleashed
By Paul Kimmel
Table of Contents
Chapter 2.  Out with the Old, In with the New

Flow Control Statements

Several flow control statements have been revised in Visual Basic .NET. GoSub is no longer supported. The Call keyword is supported but no longer required for function and subroutine calls and will probably disappear in future versions of VB .NET.

On Goto and On Gosub computed branching is no longer supported. Replace computed branch statements with the Select Case statement. On Error Goto is supported for backward compatibility but should be replaced with structured exception handling (see the section "Structured Exception Handling" for details).

The While...Wend statement block still exists, but Wend has been replaced with End While. Listing 2.14 demonstrates While...End While.

Listing 2.14 While...End While replaces While...Wend
  1:  Sub WhileEndWhileTest()  2:   3:  Dim I As Integer = 1  4:  While (I < 10)  5:  I += 1  6:  Debug.WriteLine(I)  7:  End While  8:   9:  End Sub 

The fundamental behavior of the loop hasn't changed. A While...End While loop processes zero or more times and when you type While, the End While is added automatically for you, completing the block. Use While...End While exactly as you would the VB6 While Wend loop.


Team-Fly    
Top
 


Visual BasicR. NET Unleashed
Visual BasicR. NET Unleashed
ISBN: N/A
EAN: N/A
Year: 2001
Pages: 222

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net