description | title | ms.date | helpviewer_keywords | ms.assetid | |||
---|---|---|---|---|---|---|---|
Learn more about: How to: Call a Procedure that Does Not Return a Value (Visual Basic) |
How to: Call a Procedure that Does Not Return a Value |
07/20/2015 |
|
259b49a3-a3c1-4254-ba8c-73cdc4127703 |
A Sub
procedure does not return a value to the calling code. You call it explicitly with a stand-alone calling statement. You cannot call it by simply using its name within an expression.
-
Specify the name of the
Sub
procedure. -
Follow the procedure name with parentheses to enclose the argument list. If there are no arguments, you can optionally omit the parentheses. However, using the parentheses makes your code easier to read.
-
Place the arguments in the argument list within the parentheses, separated by commas. Be sure you supply the arguments in the same order that the
Sub
procedure defines the corresponding parameters.The following example calls the Visual Basic xref:Microsoft.VisualBasic.Interaction.AppActivate%2A function to activate an application window. xref:Microsoft.VisualBasic.Interaction.AppActivate%2A takes the window title as its sole argument. It does not return a value to the calling code. If a Notepad process is not running, the example throws an xref:System.ArgumentException. The
Shell
procedure assumes the applications are in the paths specified.[!code-vbVbVbalrCatRef#11]
- xref:Microsoft.VisualBasic.Interaction.Shell%2A
- xref:System.ArgumentException
- Procedures
- Sub Procedures
- Procedure Parameters and Arguments
- Sub Statement
- How to: Create a Procedure
- How to: Call a Procedure That Returns a Value
- How to: Call an Event Handler in Visual Basic