Hi, I was wondering if there's a pointer in VBA language?
just like in C language.
For example,
Move(&c)
Function Move (int *c){
//Your code
}
'In Module1
Sub Main1()
Dim c As Long
c = 3
Move1 c
'c becomes 4
End Sub
Sub Move1(ByRef i As Long) 'Equivalent to void Move1(int& c)
i = i + 1
End Sub
'In module2
Private Declare Sub MoveMemory Lib "kernel32.dll" Alias "RtlMoveMemory" _
(ByVal Destination As Long, ByVal Source As Long, ByVal Length As Long)
Sub Main2()
Dim c As Long
c = 3
Move2 VarPtr(c) 'Equivalent to Move2(&c)
'c becomes 4
End Sub
Sub Move2(ByVal pointerOfi As Long) 'Equivalent to void Move2(int *c)
'Equivalent to *c = *c +1
Dim tempValue As Long
MoveMemory VarPtr(tempValue), pointerOfi, 4
tempValue = tempValue + 1
MoveMemory pointerOfi, VarPtr(tempValue), 4
End Sub