Wednesday, October 27, 2010

Subroutines

A subroutine simply executes code when called by another procedure.

Code eg: Subroutine.

Public Sub CalculateScore()
        ' Declare variables
        Dim TotalDamage As Integer = 555
        Dim TotalAgility As Integer = 6
        ' Create the expression
        Dim TotalPoints As Integer = TotalDamage * TotalAgility
End Sub

A subroutine does not return a value to the calling procedure.

If you need to return a value - use a function.

No comments:

Post a Comment