-
Quick question that should be easy for the experienced. I am trying to pass a variable's adderss as a parameter of a function. How do I write that in VB code. In C++ I would just put niftyfunciton(&variable) but the & in VB is for concatination. Whats the notation for passing a reference in VB?
-
VB passes everything by reference by default. You can add the ByRef keyword in the declaration if you want to be explicit.
John
-
I'm not entirely sure what you're trying to do.
you can pass a variable ByRef to a Function by specifying it in the Declaration
Code:
Private Sub AddOne(ByRef Number as Long)
Number = Number + 1
End Sub
will add one to what's stored in the variable passed to it.
If you want a Pointer to a Variable you can use
VarPtr(MyVar) which returns a long pointer to MyVar, I'ts pretty useless in VB Though unless you wan't to do some really wierd stuff with APIs that you could do without pointers.