CitectVBA Programming Reference > CitectVBA Function Reference > Procedural Statements > Sub

Sub

Declares and defines a subroutine procedure, its name, parameters, and code to be enacted upon when the subroutine is called. Subroutines differ from functions in that functions return a value, whereas subroutines do not.

The required SubroutineName is the name of the subroutine being declared.

The optional ArgList is the list of arguments used within the subroutine.

A CitectVBA subroutine starts with the SUB statement and finishes with the END SUB statement. All other statements that lie between the SUB and END SUB statements, will be executed by the subroutine, when called to do so.

Syntax

Sub

Related Functions

Call | End Function | End Sub | Exit

Example

Function GetColor2( c% ) As Long
GetColor2 = c% * 25
If c% > 2 Then
GetColor2 = 255 ' 0x0000FF - Red
End If
If c% > 5 Then
GetColor2 = 65280 ' 0x00FF00 - Green
End If
If c% > 8 Then
GetColor2 = 16711680 ' 0xFF0000 - Blue
End If
End Function

Sub TestColor2
Dim I as integer
For I = 1 to 10
Print GetColor2(I)
Next I
End Sub