'Functions are different from procedures in Visual Basic'because they must return a value.'Here is two different ways to use functions...PublicClass Form1
Inherits System.Windows.Forms.Form
'Here is two different ways to use functions...Dim X AsInteger'Part I'''''''''''''''''''''''''''''''uses a function without argumentPrivateFunction myFunc1()
myFunc1 = X + 5 'add x with 5 and return valueEndFunctionPrivateSub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
X = 5 'set X = 5
TextBox1.Text = myFunc1() 'write return value of the function myFunc1EndSub'END Part I'''''''''''''''''''''''''''Part II''''''''''''''''''''''''''''''uses a function with argumentPrivateFunction myFunc2(ByVal Y AsInteger)
myFunc2 = Y + 5 'add Y with 5 and return valueEndFunctionPrivateSub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
TextBox2.Text = myFunc2(5) 'write return value of the function myFunc2EndSub'END Part II'''''''''''''''''''''''''EndClass
Visual Basic .Net Source Code
I hope you found this VB .Net tutorial useful!
Don't forget to mention Apron Tutorials in your References!