Sub 程序

Sub 程序是以 Sub 和 End Sub 陳述式括住的一系列 BSL 陳述式,可執行動作但不會傳回值。Sub 程序可以採用引數 (常數、變數或由呼叫程序傳遞的表示式)。如果 Sub 程序沒有引數,則其 Sub 陳述式必須包含一組空的括號 ()。

下列範例說明 Sub 程序的用法:

範例

Sub CalculateArea()
    Dim length, width, area
    length = 5
    width = 4
    area = length * width   ' Calculates the area of the rectangle.
    'The area of the rectangle is 20
End Sub
Call CalculateArea()