stu nicholls dot com | menu - Professional dropdown #3



Procedures and Function
Defining Procedures Syntax:
Public| Protected |Friend |Protected Friend |Private Sub subname [(argumentlist)]
Statements
End Sub

Example:
Sub MySub (ByVal S1 As String)
System.console.writeline(S1);
End Sub

Return and Exit Sub

Note: Parameters to the Functions and Procedures can be passed by Value or by Reference

Preserving a variables value between procedure call Example
Module Module1
Sub Main()
Dim loopIndex As Integer, intValue = 0
For loopIndex = 0 To 3
intValue = Count_on()
System.Console.WriteLine(intValue)
Next loopIndex
End Sub
Function Count_on() As Integer
Static countValue As Integer = 0
countValue += 1
Return countValue
End Function
End Module

<< Previous   Next>>


comments powered by Disqus
Footer1