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 |
What are the naming conventions while declaring a variable in the vbscript language?
explain with example primitive data types of vb script.
Which function allows you to instantiate an object given its programmatic identifier or progid?
Differentiate javascript and vbscript?
How will you convert a string to upper case string using vbscript?
Which object is used to work with the excel sheets in the vbscript language and what statement is used to create this object?
How do you create a recordset object in VBScript?
how to find number of characters(letter a) in the sentence Rain Rain Go away
I have string like hp company.print tis like company hp.write a program in vbscripting
What are the 2 ways in which a variable can be declared in the vbscript language?
Find Out Length of an array without using Ubound?
In our application qtp unable to indentify the menu items,we tried number of times to add objetcs into object repository but fail. through normal recording mode only objects going to add into repository but while running same recording script qtp showing a error like " unable to indentify the object". in repository there is no any properties and pro values for that object and also i tried with virtual object config also unable to find the object in application and in repository. Then what i have to do to identify menu objects????? can anybody hell me pls..............