So What is ByVal?
I'm just beginer in VB so i know practicaly nothing in it.
By the way thanks for everyone who answered my previous posts and who will answer this one.
------------------
-casparas
novice programer
[email protected]
Printable View
So What is ByVal?
I'm just beginer in VB so i know practicaly nothing in it.
By the way thanks for everyone who answered my previous posts and who will answer this one.
------------------
-casparas
novice programer
[email protected]
ByVal means To Pass By Value, meaning you you pass something ByVal you are passing the Value of the Variable not a Pointer to the Variable itself, ie.
Calling this code would always Print "2" in the Debug Window.Code:Private Sub Command1_Click()
Dim iTemp As Integer
iTemp = 2
Call Add2(iTemp)
Debug.Print iTemp
End Sub
Private Sub Add2(ByVal X As Integer)
X = X + 2
End Sub
If you modify the Add2 Routine to be ByReference, it would Print "4".
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
One other thing to note. ByRef is the VB default way of passing variable. If you don't specify, it will be ByRef.
Roger Eagans