Back to index

Sub statement
Declares the name, arguments, and code that define a Sub procedure.

Format:

  Sub name [(arglist)] 
     [ statements ]
     [ Exit Sub ]
     [ statements ]
  End Sub

Syntax:

Remarks:

1. You can't define a Sub procedure inside another procedure.

2. The Exit Sub statement causes an immediate exit from a Sub procedure. Any number of Exit Sub statements can appear anywhere in the procedure.

4. It's possible to call other functions and subs in function procedure but they have to be declared before current sub.

5. SBasic supports recursion calls, it means you can call current Sub inside it's body.

See also:

- Recursion and functions
- Exit statement
- Function statement

Example:


  Sub WriteSomeLine(s as String)
     Print
     Print s
     Print
  End Function 

  ' -----------------------------------
  WriteSomeLine("some text")
  Input 



Copyright (c) 2000-2006 by Smartphoneware. All rights reserved.