What is the difference between ByRef and ByVal.
When to use ByRef and ByVal
Answers were Sorted based on User's Feedback
Answer / cybergh0st
Byval refers to the actual value of the variable. ByRef
refers to the location of where the value is stored.
Passing.
| Is This Answer Correct ? | 44 Yes | 2 No |
Answer / sagar mitra
ByRef refers to the location, ByVal refers to the actual value. Also, if you are passing parameters with "ByVal" then even if the parameter values are changed, the original argument values will remain intact. But if you pass using "ByRef" then if the parameter values are changed, then the original argument value is also modified
| Is This Answer Correct ? | 26 Yes | 1 No |
Answer / akshitha
Arguments r of 2 types-
byval & byref
byval-when a method is called using by value & an argument
is passed & if the value of that argument is modified within
that method,orginal argument is not modified
byref-when a method is called by reference & an argument is
passed & if the value of that argument is modified within
that method,original argument is modified
| Is This Answer Correct ? | 31 Yes | 12 No |
Answer / 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 |
Answer / fgf
Small correction: we have to call the function
Function abc(ByRef var)
var=var+1
End Function
Dim x:x=2
Call abc(x)
Msgbox x
| Is This Answer Correct ? | 8 Yes | 1 No |
Can automation testing find ssame no. of bugs what we can find by manual testing?
How do you declare a variable in vbscript?
Explain few date functions in vbscript?
How will you convert a given number to long in vbscript?
how to increase the values in text box in a given text box increament by two values by clicking on button
create a form to accept username and password validate the username and password with using message box, display the corresponding user message
Which data type/types are supported by vbscript language and what are their specialties?
this q asked in applabs, q is: QTP should open google.com page and enter "qtp" in one edit(search) box and click search and should open google.com again and enter "job" in edit(search) box and click on search. I tried this but getting error "Edit(search) box matches more than one object", could anyone this question plz..
How to throw an error in vbscript?
We have 1 web page with names column. I am giving the Service Providers1,2,3.... @ that time dynamically some no of names are displaying in the webpage and The Pop up windows are opening(No.of Pop Up windows=No.of Names). The names may be diffar for each and every Service Provders (Dynamically) How can we handle the Dynamic values?
The function template cocept is implemented in vb.net is ???
i created script for login in QTP,i parametirized that using global sheet,problem i am facing is first i want to login with first values provided in excelsheet and want to perform some operation,second time if call same action it should login with second values in excelsheet