Print Page | Close Window

Passing by value vs Passing by reference

Printed From: One Stop Testing
Category: Testing Tools @ OneStopTesting
Forum Name: QuickTest Pro @ OneStopTesting
Forum Discription: QuickTest Pro is a fresh approach to automated software and application testing that addresses testing needs of both business analysts and Quality Assurance professionals.
URL: http://forum.onestoptesting.com/forum_posts.asp?TID=7036
Printed Date: 27Jun2024 at 6:42am


Topic: Passing by value vs Passing by reference
Posted By: Mithi25
Subject: Passing by value vs Passing by reference
Date Posted: 22Sep2009 at 2:20am

Passing by value vs Passing by reference

Here is a QTP quiz for you. We have two functions below. For the first one, argument is passed by reference while for the second, argument is passed by value.

A. Argument is passed by Reference

Function learnqtp( ByRef var)

    myname= "jain"

    msgbox var

    msgbox myname

End Function

myname= "ankur"

call learnqtp (myname)

B. Argument is passed by Value:

Function learnqtp( ByVal var)

    myname= "jain"

    msgbox var

msgbox myname

End Function

myname= "ankur"

call learnqtp (myname)

Without copying the functions in your QTP editor, try to find:

  1. Output of A.
  2. Output of B.

Why do you think output differ/doesn’t differ? Give your answers in comment below. Now, open QTP and check your answers. Any more comments? :%29





-------------
http://www.quick2sms.com - Send Unlimited FREE SMS to Any Mobile Anywhere in INDIA,
Click Here



Print Page | Close Window