Sideway
output.to from Sideway
Draft for Information Only

Content

VB.NET Transfer Control Statements
  Call Statement
  Syntax
  Parts
  Remarks
  See also
  Continue Statement
  Syntax
  Remarks
  See also
 Exit Statement
  Syntax
  Statements
  Remarks
  See also
 GoTo Statement
  Syntax
  Part
  Remarks
  Branching and Try Constructions
  See also
 Resume Statement
  Syntax
  Parts
  Remarks
  Requirements
  See also
  Return Statement
  Syntax
  Part
  Remarks
  See also
 Source/Reference

VB.NET Transfer Control Statements

The supporting VB.NET Transfer Control Statements are Call, Continue, Exit, GoTo, Resume, Return,        With

Call Statement

Transfers control to a Function, Sub, or dynamic-link library (DLL) procedure.

Syntax

[ Call ] procedureName [ (argumentList) ]  

Parts

procedureName Required. Name of the procedure to call.
argumentList Optional. List of variables or expressions representing arguments that are passed to the procedure when it is called. Multiple arguments are separated by commas. If you include argumentList, you must enclose it in parentheses.

Remarks

You can use the Call keyword when you call a procedure. For most procedure calls, you aren’t required to use this keyword.

You typically use the Call keyword when the called expression doesn’t start with an identifier. Use of the Call keyword for other uses isn’t recommended.

If the procedure returns a value, the Call statement discards it.

See also

Continue Statement

Transfers control immediately to the next iteration of a loop.

Syntax

Continue { Do | For | While }  

Remarks

You can transfer from inside a Do, For, or While loop to the next iteration of that loop. Control passes immediately to the loop condition test, which is equivalent to transferring to the For or While statement, or to the Do or Loop statement that contains the Until or While clause.

You can use Continue at any location in the loop that allows transfers. The rules allowing transfer of control are the same as with the GoTo Statement.

For example, if a loop is totally contained within a Try block, a Catch block, or a Finally block, you can use Continue to transfer out of the loop. If, on the other hand, the Try...End Try structure is contained within the loop, you cannot use Continue to transfer control out of the Finally block, and you can use it to transfer out of a Try or Catch block only if you transfer completely out of the Try...End Try structure.

If you have nested loops of the same type, for example a Do loop within another Do loop, a Continue Do statement skips to the next iteration of the innermost Do loop that contains it. You cannot use Continue to skip to the next iteration of a containing loop of the same type.

If you have nested loops of different types, for example a Do loop within a For loop, you can skip to the next iteration of either loop by using either Continue Do or Continue For.

See also

Exit Statement

Exits a procedure or block and transfers control immediately to the statement following the procedure call or the block definition.

Syntax

Exit { Do | For | Function | Property | Select | Sub | Try | While }  

Statements

Exit Do
Immediately exits the Do loop in which it appears. Execution continues with the statement following the Loop statement. Exit Do can be used only inside a Do loop. When used within nested Do loops, Exit Do exits the innermost loop and transfers control to the next higher level of nesting.

Exit For
Immediately exits the For loop in which it appears. Execution continues with the statement following the Next statement. Exit For can be used only inside a For...Next or For Each...Next loop. When used within nested For loops, Exit For exits the innermost loop and transfers control to the next higher level of nesting.

Exit Function
Immediately exits the Function procedure in which it appears. Execution continues with the statement following the statement that called the Function procedure. Exit Function can be used only inside a Function procedure.

To specify a return value, you can assign the value to the function name on a line before the Exit Function statement. To assign the return value and exit the function in one statement, you can instead use the Return Statement.

Exit Property
Immediately exits the Property procedure in which it appears. Execution continues with the statement that called the Property procedure, that is, with the statement requesting or setting the property's value. Exit Property can be used only inside a property's Get or Set procedure.

To specify a return value in a Get procedure, you can assign the value to the function name on a line before the Exit Property statement. To assign the return value and exit the Get procedure in one statement, you can instead use the Return statement.

In a Set procedure, the Exit Property statement is equivalent to the Return statement.

Exit Select
Immediately exits the Select Case block in which it appears. Execution continues with the statement following the End Select statement. Exit Select can be used only inside a Select Case statement.

Exit Sub
Immediately exits the Sub procedure in which it appears. Execution continues with the statement following the statement that called the Sub procedure. Exit Sub can be used only inside a Sub procedure.

In a Sub procedure, the Exit Sub statement is equivalent to the Return statement.

Exit Try
Immediately exits the Try or Catch block in which it appears. Execution continues with the Finally block if there is one, or with the statement following the End Try statement otherwise. Exit Try can be used only inside a Try or Catch block, and not inside a Finally block.

Exit While
Immediately exits the While loop in which it appears. Execution continues with the statement following the End While statement. Exit While can be used only inside a While loop. When used within nested While loops, Exit While transfers control to the loop that is one nested level above the loop where Exit While occurs.

Remarks

Do not confuse Exit statements with End statements. Exit does not define the end of a statement.

See also

GoTo Statement

Branches unconditionally to a specified line in a procedure.

Syntax

GoTo line  

Part

line
Required. Any line label.

Remarks

The GoTo statement can branch only to lines in the procedure in which it appears. The line must have a line label that GoTo can refer to. For more information, see How to: Label Statements.

Note

GoTo statements can make code difficult to read and maintain. Whenever possible, use a control structure instead. For more information, see Control Flow.

You cannot use a GoTo statement to branch from outside a For...Next, For Each...Next, SyncLock...End SyncLock, Try...Catch...Finally, With...End With, or Using...End Using construction to a label inside.

Branching and Try Constructions

Within a Try...Catch...Finally construction, the following rules apply to branching with the GoTo statement.

Block or region Branching in from outside Branching out from inside
Try block Only from a Catch block of the same construction 1 Only to outside the whole construction
Catch block Never allowed Only to outside the whole construction, or to the Try block of the same construction 1
Finally block Never allowed Never allowed

1 If one Try...Catch...Finally construction is nested within another, a Catch block can branch into the Try block at its own nesting level, but not into any other Try block. A nested Try...Catch...Finally construction must be contained completely in a Try or Catch block of the construction within which it is nested.

The following illustration shows one Try construction nested within another. Various branches among the blocks of the two constructions are indicated as valid or invalid.

Graphic diagram of branching in Try constructions

See also

Resume Statement

Resumes execution after an error-handling routine is finished.

We suggest that you use structured exception handling in your code whenever possible, rather than using unstructured exception handling and the On Error and Resume statements. For more information, see Try...Catch...Finally Statement.

Syntax

Resume [ Next | line ]  

Parts

Resume
Required. If the error occurred in the same procedure as the error handler, execution resumes with the statement that caused the error. If the error occurred in a called procedure, execution resumes at the statement that last called out of the procedure containing the error-handling routine.

Next
Optional. If the error occurred in the same procedure as the error handler, execution resumes with the statement immediately following the statement that caused the error. If the error occurred in a called procedure, execution resumes with the statement immediately following the statement that last called out of the procedure containing the error-handling routine (or On Error Resume Next statement).

line
Optional. Execution resumes at the line specified in the required line argument. The line argument is a line label or line number and must be in the same procedure as the error handler.

Remarks

Note

We recommend that you use structured exception handling in your code whenever possible, rather than using unstructured exception handling and the On Error and Resume statements. For more information, see Try...Catch...Finally Statement.

If you use a Resume statement anywhere other than in an error-handling routine, an error occurs.

The Resume statement cannot be used in any procedure that contains a Try...Catch...Finally statement.

Requirements

Namespace: Microsoft.VisualBasic

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

See also

Return Statement

Returns control to the code that called a Function, Sub, Get, Set, or Operator procedure.

Syntax

Return  
-or-  
Return expression  

Part

expression
Required in a Function, Get, or Operator procedure. Expression that represents the value to be returned to the calling code.

Remarks

In a Sub or Set procedure, the Return statement is equivalent to an Exit Sub or Exit Property statement, and expression must not be supplied.

In a Function, Get, or Operator procedure, the Return statement must include expression, and expression must evaluate to a data type that is convertible to the return type of the procedure. In a Function or Get procedure, you also have the alternative of assigning an expression to the procedure name to serve as the return value, and then executing an Exit Function or Exit Property statement. In an Operator procedure, you must use Return expression.

You can include as many Return statements as appropriate in the same procedure.

Note

The code in a Finally block runs after a Return statement in a Try or Catch block is encountered, but before that Return statement executes. A Return statement cannot be included in a Finally block.

See also

 

Source/Reference


©sideway

ID: 200800011 Last Updated: 8/11/2020 Revision: 0 Ref:

close

References

  1. Active Server Pages,  , http://msdn.microsoft.com/en-us/library/aa286483.aspx
  2. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929%28v=vs.90%29.aspx
  3. ASP Best Practices,  , http://technet.microsoft.com/en-us/library/cc939157.aspx
  4. ASP Built-in Objects,  , http://msdn.microsoft.com/en-us/library/ie/ms524716(v=vs.90).aspx
  5. Response Object,  , http://msdn.microsoft.com/en-us/library/ms525405(v=vs.90).aspx
  6. Request Object,  , http://msdn.microsoft.com/en-us/library/ms524948(v=vs.90).aspx
  7. Server Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525541(v=vs.90).aspx
  8. Application Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525360(v=vs.90).aspx
  9. Session Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms524319(8v=vs.90).aspx
  10. ASPError Object,  , http://msdn.microsoft.com/en-us/library/ms524942(v=vs.90).aspx
  11. ObjectContext Object (IIS),  , http://msdn.microsoft.com/en-us/library/ms525667(v=vs.90).aspx
  12. Debugging Global.asa Files,  , http://msdn.microsoft.com/en-us/library/aa291249(v=vs.71).aspx
  13. How to: Debug Global.asa files,  , http://msdn.microsoft.com/en-us/library/ms241868(v=vs.80).aspx
  14. Calling COM Components from ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524620(v=VS.90).aspx
  15. IIS ASP Scripting Reference,  , http://msdn.microsoft.com/en-us/library/ms524664(v=vs.90).aspx
  16. ASP Keywords,  , http://msdn.microsoft.com/en-us/library/ms524672(v=vs.90).aspx
  17. Creating Simple ASP Pages,  , http://msdn.microsoft.com/en-us/library/ms524741(v=vs.90).aspx
  18. Including Files in ASP Applications,  , http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx
  19. ASP Overview,  , http://msdn.microsoft.com/en-us/library/ms524929(v=vs.90).aspx
  20. FileSystemObject Object,  , http://msdn.microsoft.com/en-us/library/z9ty6h50(v=vs.84).aspx
  21. http://msdn.microsoft.com/en-us/library/windows/desktop/ms675944(v=vs.85).aspx,  , ADO Object Model
  22. ADO Fundamentals,  , http://msdn.microsoft.com/en-us/library/windows/desktop/ms680928(v=vs.85).aspx
close

Latest Updated LinksValid XHTML 1.0 Transitional Valid CSS!Nu Html Checker Firefox53 Chromena IExplorerna
IMAGE

Home 5

Business

Management

HBR 3

Information

Recreation

Hobbies 8

Culture

Chinese 1097

English 339

Reference 79

Computer

Hardware 249

Software

Application 213

Digitization 32

Latex 52

Manim 205

KB 1

Numeric 19

Programming

Web 289

Unicode 504

HTML 66

CSS 65

SVG 46

ASP.NET 270

OS 429

DeskTop 7

Python 72

Knowledge

Mathematics

Formulas 8

Algebra 84

Number Theory 206

Trigonometry 31

Geometry 34

Coordinate Geometry 2

Calculus 67

Complex Analysis 21

Engineering

Tables 8

Mechanical

Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5

Control

Process Control 1

Acoustics 19

FiniteElement 2

Natural Sciences

Matter 1

Electric 27

Biology 1

Geography 1


Copyright © 2000-2024 Sideway . All rights reserved Disclaimers last modified on 06 September 2019