|
|
 |
'Functions are different from procedures in Visual Basic
'because they must return a value.
'Here is two different ways to use functions...
'General
Dim X As Integer
'Part I''''''''''''''''''''''''''''''
'uses a function without in parameter
Private Function myFunc1()
myFunc1 = X + 5 'add x with 5 and return value
End Function
Private Sub Command1_Click()
X = 5 'set X = 5
Text1.Text = myFunc1 'write return value of the function myFunc1
End Sub
'END Part I''''''''''''''''''''''''''
'Part II'''''''''''''''''''''''''''''
'uses a function with in parameter
Private Function myFunc2(Y As Integer)
myFunc2 = Y + 5 'add Y with 5 and return value
End Function
Private Sub Command2_Click()
Text2.Text = myFunc2(5) 'write return value of the function myFunc2
End Sub
'END Part II'''''''''''''''''''''''''
Private Sub Form_Load()
End Sub
|
 |
Visual Basic Source Code |
I hope you found this Visual Basic tutorial useful!
Don't forget to mention Apron Tutorials in your References!
Best Regards
Ronny André Reierstad
|
|
|