Siebel VB Language Reference > Methods Reference for Siebel VB > Code Setup and Control Methods >

Create Subroutine Method


The Create Subroutine method is a control structure that defines a subroutine. It does not return a value. It returns flow to the caller when Siebel VB encounters the End Sub statement or an Exit Sub statement.

Format

[Static] [Private] Sub name [([Optional] argument [As type], ...)]
End Sub

The following table describes the arguments that you can use with this method.

Argument
Description

name

The name of the subroutine.

argument

A list of argument names that includes commas that separate each name. For more information, see Specifying Arguments.

type

The data type of the argument.

Usage

Note the following:

  • For important caution information, see Caution About Writing a Custom Function or Subroutine.
  • A call to a subroutine stands alone as a separate statement. For more information, see Call Subroutine Method).
  • Siebel VB supports recursion.
  • A Visual Basic procedure passes values through reference. This means that if a procedure assigns a value to an argument, then it modifies the variable that the caller passes. You must use this feature with caution. For more information, see Pass Values Through Reference.
  • You must use the Create Function method rather than the Create Subroutine method to define a procedure that includes a return value. For more information, see Create Function Method.
Usage for the Static Keyword and Private Keyword

The Static keyword specifies that any variable you declare in this method retains a value as long as the code runs. This situation applies regardless of how you declare variables in this method.

The Private keyword specifies that other functions and subroutines in other modules cannot access the subroutine that you define with this method. Only procedures defined in the same module can access a private function.

Specifying Arguments

Note the following:

  • To specify multiple arguments, you can use a list of variable names where a comma separates each name.
  • To specify the data type of an argument, you can use a type character or the As clause.
  • To declare a record argument, you use the As clause and a value in the type argument. You must have already used the Type statement to define this value in the type argument.
  • To declare an array argument, you can use empty parentheses after the argument. You do not specify array dimensions in the Create Subroutine method. You must use a consistent number of dimensions for every reference to an array argument that occurs in the body of the Create Subroutine code.
Declaring Optional Arguments

If you declare an optional argument, then you can omit the value for this argument when Siebel VB calls the method that contains this argument. Note the following:

  • You can only declare a variant argument as optional.
  • Any optional arguments must occur after the required arguments in the Create Subroutine method.
  • You can use the IsMissing method to determine if an optional argument is omitted. For more information, see Is Optional Argument Missing Method. For more information on using named arguments, see Comments and Call Subroutine Method.
Example

The following example is a subroutine that uses the Create Subroutine method:

Sub Button1_Click
   'Hello, World.
End Sub

Related Topics

Declare Variable Statement
Create Function Method
Declare Global Variable Statement
Force Explicit Declaration Statement
Declare Global Variable Statement

Siebel VB Language Reference Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Legal Notices.