Professional Documents
Culture Documents
• Accessibility :
– Private, Public, Protected, Friend, Protected Friend
• Return :
– Syntax : Return(expression)
– Eg : Return (f)
– By default value will return with the help of function
name itselt
– It can also be returned by the user
• Advantages :
– Causes immediate exit from the fn
– Returns the needed value to the fn
Calling Fns…
• Call by Value :
– Values passed to the fns are passed to fns as
arguments
– Public Function factorial(ByVal x As Integer) As Integer
• Call by Reference
– Values are passed as references and so if the
values gets affected inside the fn it will reflect in
the main calling fn
– Public Function factorial(ByRef x As Integer) As Integer
Functions Eg Pgm…
Coding…
• Procedure Button Sub swap(ByVal x As Integer, ByVal
Click: y As Integer) ' procedure call
' local variable Dim temp As Integer
definition temp = x
a = TextBox1.Text x=y
b = TextBox2.Text y = temp
' calling a procedure ' ' Procedure cant return values
swap(a, b) a=x
TextBox1.Text = a b=y
TextBox2.Text = b End Sub
Coding…
• Sum(call by value) button Public Function sumfn(ByVal x As Integer, ByVal y
As Integer) As Integer ' call by value
Dim temp As Integer
MsgBox(sumfn(TextBox1. temp = x + y
Text, TextBox2.Text)) Return temp
End Function