Procedures may or not require parameters to execute.
Subroutine
When the behavior simply needs to execute some code, we use a subroutine.
Code eg 1: Subroutine with no parameters
Public Sub NameOfBehavior()
'Code does something
End Sub
'Code does something
End Sub
Code eg 2: Subroutine with parameters
Public Sub Login(UserName: String, Password: String)
'Code does something with parameters...
End Sub
'Code does something with parameters...
End Sub
Function
When the behavior is required to return a value to calling procedure, we use a function.
Code eg 1: Function with no parameters
Public Function NameOfFunction() As String
'Code does something
Return "Sample return String"
End Sub
'Code does something
Return "Sample return String"
End Sub
Code eg 2: Function with parameters
'Code does something with parameters...
Return LastName
End Sub
No comments:
Post a Comment