I would like to know if Access VBA has the similar feature as VB in terms of passing parameters with byref and byval. In the following sample program, the value is changed to true in the sub but when it is passed back to the calling program, it still carries false.
In the calling program:
dim blnDeleted as boolean
blnDeleted = false
ChkIfDeleted(blnDeleted)
msgbox blnDeleted
...
...
...
end sub
public sub ChkIfDeleted(byRef blnDel as boolean)
...
...
...
blnDel = true
msgbox blnDel
end sub
byref and byval
-
- Administrator
- Posts: 78676
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: byref and byval
The line
ChkIfDeleted (blnDeleted)
passes blnDeleted as a ByVal argument because you enclose it in parentheses. You should use either
ChkIfDeleted blnDeleted
or
Call ChkIfDeleted(blnDeleted)
ChkIfDeleted (blnDeleted)
passes blnDeleted as a ByVal argument because you enclose it in parentheses. You should use either
ChkIfDeleted blnDeleted
or
Call ChkIfDeleted(blnDeleted)
Best wishes,
Hans
Hans
-
- PlutoniumLounger
- Posts: 15667
- Joined: 24 Jan 2010, 23:23
- Location: brings.slot.perky
Re: byref and byval
Good call!HansV wrote:... because you enclose it in parentheses.
He who plants a seed, plants life.
-
- StarLounger
- Posts: 77
- Joined: 26 Apr 2011, 05:10
Re: byref and byval
Thanks Hans. Clearly it is different from VB.