What is the difference between ByRef and ByVal.
When to use ByRef and ByVal
Answer Posted / manjunathareddy
ByVal :- Byval is address the actual value of the variable.
Ex:- Function abc(Byval var)
var=var+1
End Function
Dim x:x=2
abc x
Msgbox x
In Above example 2 is the Actual value so it address the
actual value,the Result is 2.
ByRef:- ByRef is address the Location of the Stored variable.
Function abc(ByRef var)
var=var+1
End Function
Dim x:x=2
abc x
Msgbox x
In above example it 2 actual value but in byref it refers
the location of the stored variable the result is 3.
| Is This Answer Correct ? | 13 Yes | 1 No |
Post New Answer View All Answers
Compare java script and vb script?
What are the rules to name variable in vbscript?
What is byref and byval parameters in vbscript?
How to declare an array in vbscript?
Write a function for Instr(). We need to write a function that works as same as Instr(). Code or Even pseudo code is good enough for me.?
How can you fetch the value of a cookie?
What is vbscript?
What are the special sub-types in vbscript?
Explain the constants in vbscript?
Difference between dim,public and private variables in vb script?
how to check whether link is disabled in QTP??
How to Import data from a file (file is on the desktop) to the data table
what is event handling?
How will you get a combined string from array of string in vbscript?
What are the differences between sub procedures and function procedures?