What is the difference between ByRef and ByVal.
When to use ByRef and ByVal

Answers were Sorted based on User's Feedback



What is the difference between ByRef and ByVal. When to use ByRef and ByVal..

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

What is the difference between ByRef and ByVal. When to use ByRef and ByVal..

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

What is the difference between ByRef and ByVal. When to use ByRef and ByVal..

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

What is the difference between ByRef and ByVal. When to use ByRef and ByVal..

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

What is the difference between ByRef and ByVal. When to use ByRef and ByVal..

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

Post New Answer

More VB Script Interview Questions

What are the naming conventions while declaring a variable in the vbscript language?

0 Answers  


explain with example primitive data types of vb script.

1 Answers  


Which function allows you to instantiate an object given its programmatic identifier or progid?

0 Answers  


Differentiate javascript and vbscript?

0 Answers  


How will you convert a string to upper case string using vbscript?

0 Answers  


Which object is used to work with the excel sheets in the vbscript language and what statement is used to create this object?

0 Answers  


How do you create a recordset object in VBScript?

3 Answers  


how to find number of characters(letter a) in the sentence Rain Rain Go away

4 Answers  


I have string like hp company.print tis like company hp.write a program in vbscripting

1 Answers   HP,


What are the 2 ways in which a variable can be declared in the vbscript language?

0 Answers  


Find Out Length of an array without using Ubound?

1 Answers  


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..............

2 Answers   Blue Star,


Categories