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

how to automatically update the sql server2005 database records when insert in vb6?

1485


Explain the operator precedence in vb script?

656


How can you create an object in vbscript?

615


What are class properties?

653


Can automation testing find ssame no. of bugs what we can find by manual testing?

1468






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

560


who will create the object?

1721


Which in-built functions are used to convert the specified expression in the form of date and string in the vbscript language?

541


Explain the tristate constants in vbscript?

561


How to access array data?

545


How will you get the largest subscript of an array in vbscript?

605


wht must be the interview question on corinthian information technology solutions incorporated.

2186


Explain the adodb.stream class?

545


How many types of operators are available in the vbscript language?

537


Explain the string concatenation function in vbscript?

539