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

Why is error handling required?

0 Answers  


how to write function to validate the number of characters entering into the text box?

2 Answers   TCS,


How will you get a random number between 0 and 1 in vbscript?

0 Answers  


compare the string without using stringcomp function?

1 Answers   CSS Corp,


can anyone tell me the procedure of interview held in applabs

0 Answers  






write a vb script to add two 2*2 matrix

2 Answers  


which is the best institute in banglaore for software testing?

1 Answers  


Explain about scrrun.dll?

0 Answers  


Write VB script to convert from feet to inches(hint 1feet=12 inches)

2 Answers  


explain with example primitive data types of vb script.

1 Answers  


Hellow friends, I am learning QTP,but here problem is VB script. please guide me how to learn VB script w.r.t QTP and if you know any books tell me or if you have any materials or any use full material or any else w.r.t QTP please post me p.p.sekhar

0 Answers  


write a program to display the system specifications of client system with the help of vb script.

1 Answers  


Categories