Goran Level: Moderator
 Registered: 16-05-2002 Posts: 1681
|
Re: Value type and reference type ?
Code example.... Lets say you have this code in some subroutine:
Dim x as int16
x=10
changevalue x
msgbox x
private sub changevalue(y as int16)
y=20
end sub
If you run this code, changing value of y variable will not affect x variable's value, cause copy of argument is passed to procedure (default in VB.NET is byval, which is opposite to VB6, where byref is default). If you add byref in front of y asrgument, then procedure takes the actual address of variable, and any change to y also affects x, so x value will be 20.
____________________________
If you find the answer helpful, please mark this topic as solved.
|