Passing a variable (Class) to a sub and using the passed variable to make changes results in the calling routine having its copy adjusted suggesting that BYVAL is not being used for Class objects.
Example Code
```
Class Switch
Public Name
Public IP
End Class
sub Test(byval lsw)
lsw.Name = "From Sub"
end sub
set LSwitch = new Switch
LSwitch.Name = "Outside"
writeline("Name : " & LSwitch.Name)
Test LSwitch
writeline("Name : " & LSwitch.Name)
```
Resulting Output :
```
Name : Outside
Name : From Sub
```
Comments: Hi egooner, Yes, a VBScript object variable holds a _reference_ to the object. The confusing part is that the reference can be passed by value or by reference! You can see the difference by changing `Test` as follows: ``` VB sub Test(byval lsw) set lsw = new Switch lsw.Name = "From Sub" end sub ``` Cheers!
Example Code
```
Class Switch
Public Name
Public IP
End Class
sub Test(byval lsw)
lsw.Name = "From Sub"
end sub
set LSwitch = new Switch
LSwitch.Name = "Outside"
writeline("Name : " & LSwitch.Name)
Test LSwitch
writeline("Name : " & LSwitch.Name)
```
Resulting Output :
```
Name : Outside
Name : From Sub
```
Comments: Hi egooner, Yes, a VBScript object variable holds a _reference_ to the object. The confusing part is that the reference can be passed by value or by reference! You can see the difference by changing `Test` as follows: ``` VB sub Test(byval lsw) set lsw = new Switch lsw.Name = "From Sub" end sub ``` Cheers!