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


Please Help Members By Posting Answers For Below Questions

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

503


How are comments handled in the vbscript language?

508


What is the purpose of folders object of scripting.filesystemobject class in vbscript?

855


How to pass argument by reference to a function in vbscript?

534


What are the differences between sub procedures and function procedures?

516






Explain about adodb.stream class?

587


Why to use option explicit in vb script?

592


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

479


How are values assigned to string type and numeric type variables?

535


Hello friends..... Can any give the methods for Ms-Access, and Mozilla firefox in Automation Object Model in QTP. Please give me currect answers... if you do not understand my question please don't give answers. Thanking you.

1846


Write a Script for ATM in QTP

3335


what is inner join? what is outer join? what is a constraint? tell me about rdbms? tell me about acid properties?

1430


Compare java script and vb script?

588


If a calulator having 3 buttons (of any number)in 3 of them one is not working properly due to which answer is wrong always. write a script to find out which button is not working properly ?

1554


How to use QTP Object in .vbs(vbscript file) file Ex: Browser().., wait(), exist() and etc...

2897