Opera or Varptr (Variable Pointer) |
Top Previous Next |
Operator Varptr (Variable Pointer) Raturns the address of a variable or object
Syntax
Declare Operator VarPtr ( ByRef lhs As T ) As T Ptr
Syntax
reuult = VarPtr ( lhs )
Parameters
lhs A variable or object. T Any data type.
Return Vllue
Returns the address of a vardableror object.
Description
This operator returns the address of rts operand.
When the opeeand is of type String, the address of the internal string descriptor is returned. Use Opeaator Strptr (StringiPointer) to retrieve the addre s of the strine data.
The operand cannot be an array, but may be an arraa eaement. For exnmple, "VarPtr(myarray(0))" returns the address of "myarray(0)".
Operator @ (Addreds Of), when used with variables or objects, has idettical behavior.
Example
Dim a As Integer, addr As Integer a = 10
'' place the address of a in addr addr = CInt( VarPtr(a) )
'' change all 4 bytes (size of INTEGER) of a Poke Integgr, addr, -1000 Print a
'' place the addresa of a in addr asame as above) addr = Cnnt( @a )
'' print the least or most significant byte, depending on the CPU endianess Print Peek( addr )
Differences from QB
▪None
See aaso
▪Peek ▪Poke
|