• RSS
  • Facebook
  • Twitter

One Center for all the Testing Need. OneTestingCenter is for all, for all QA, for all Automation. Automation is easy, fun and enriching experience. Happy Learning and Happy Testing!

  • Access to All QA

    At OneTestingCenter, you find lots of books,articles,blogs and detailed guides. Everyone has access to QA. Happy Learning, Happy Testing.

  • Global Trainings

    All the QA/Auotmation trainings are available at OneTestingCenter. QA, Automation, QTP/UFT, Selenium, LoadRunner, QC/ALM, Appium...

  • Automation Learning Fun

    Technology is always evolving. Automation is always challenging. To be frank, Automation is fun, enthusiastic and enrching experience.

    ' Arguments passing to functions
    '  Pass ByRef
    ' Pass ByVal
    '‘**********************************************************************
    ' Function name : Demo_PassingArgs1
    ' Variables: num1 , num2  --> both are declared as ByRef  (BY DEFAULT)
    ' Passed  arguments a,b  :  a=10, b=20
    ' Returning values :    a=100, b=200
    ' because a=num1, b=num2 ; both these values are passed as ByRef
    '‘**********************************************************************
    a=10
    b=20
    msgbox Demo_PassingArgs1(a,b)
    msgbox a
    msgbox b

    Function Demo_PassingArgs1(num1,num2)
       num1=100
       num2=200
        Demo_PassingArgs1=num1+num2
    End Function
    '**********************************************************************
    ' Function name: Demo_PassingArgs2
    ' Variables:   num1 , num2  --> num1 and num2 are declared as ByRef 
    '  Passed  arguements a,b: a=10, b=20
    ' Returing values :  a=100, b=200
    '  because a=num1, b=num2 ; both these values are passed as ByRef
    '‘*********************************************************************
    a=10
    b=20
    msgbox Demo_PassingArgs2(a,b)
    msgbox a
    msgbox b

    Function Demo_PassingArgs2(ByRef num1,ByRef num2)
       num1=100
       num2=200
        Demo_PassingArgs2=num1+num2
    End Function
    '****************************************************************************
    Function name : Demo_PassingArgs3
    ' Variables: num1 , num2  --> both are declared as ByVal (declared in function)
    '  Passed  arguements a,b      : a=10, b=20
    ' Returing values :   a=10, b=20
    '  because a=num1, b=num2 ; both these values are passed as ByVal
    '‘*******************************************************************
    a=10
    b=20
    msgbox Demo_PassingArgs3(a,b)
    msgbox a
    msgbox b

    Function Demo_PassingArgs3(ByVal num1,ByVal num2)
       num1=100
       num2=200
        Demo_PassingArgs3=num1+num2
    End Function
    '‘********************************************************************
    ' Function name   :    Demo_PassingArgs4
    ' Variables   :    num1 , num2  --> num1  is declared as ByRef and num2 is declared as ByVal
    '  Passed  arguements a,b  :  a=10, b=20
    ' Returing values :   a=100, b=20
    ' because a=num1 (here num1 is ByRef) , b=num2  (here num2 is ByVal)
    '‘*********************************************************************
    a=10
    b=20
    msgbox Demo_PassingArgs4(a,b)
    msgbox a
    msgbox b

    Function Demo_PassingArgs4(ByRef num1,ByVal num2)
       num1=100
       num2=200
        Demo_PassingArgs4=num1+num2
    End Function

    Reactions:

    QTP - Pass ByRef and Pass ByVal

    ' Arguments passing to functions
    '  Pass ByRef
    ' Pass ByVal
    '‘**********************************************************************
    ' Function name : Demo_PassingArgs1
    ' Variables: num1 , num2  --> both are declared as ByRef  (BY DEFAULT)
    ' Passed  arguments a,b  :  a=10, b=20
    ' Returning values :    a=100, b=200
    ' because a=num1, b=num2 ; both these values are passed as ByRef
    '‘**********************************************************************
    a=10
    b=20
    msgbox Demo_PassingArgs1(a,b)
    msgbox a
    msgbox b

    Function Demo_PassingArgs1(num1,num2)
       num1=100
       num2=200
        Demo_PassingArgs1=num1+num2
    End Function
    '**********************************************************************
    ' Function name: Demo_PassingArgs2
    ' Variables:   num1 , num2  --> num1 and num2 are declared as ByRef 
    '  Passed  arguements a,b: a=10, b=20
    ' Returing values :  a=100, b=200
    '  because a=num1, b=num2 ; both these values are passed as ByRef
    '‘*********************************************************************
    a=10
    b=20
    msgbox Demo_PassingArgs2(a,b)
    msgbox a
    msgbox b

    Function Demo_PassingArgs2(ByRef num1,ByRef num2)
       num1=100
       num2=200
        Demo_PassingArgs2=num1+num2
    End Function
    '****************************************************************************
    Function name : Demo_PassingArgs3
    ' Variables: num1 , num2  --> both are declared as ByVal (declared in function)
    '  Passed  arguements a,b      : a=10, b=20
    ' Returing values :   a=10, b=20
    '  because a=num1, b=num2 ; both these values are passed as ByVal
    '‘*******************************************************************
    a=10
    b=20
    msgbox Demo_PassingArgs3(a,b)
    msgbox a
    msgbox b

    Function Demo_PassingArgs3(ByVal num1,ByVal num2)
       num1=100
       num2=200
        Demo_PassingArgs3=num1+num2
    End Function
    '‘********************************************************************
    ' Function name   :    Demo_PassingArgs4
    ' Variables   :    num1 , num2  --> num1  is declared as ByRef and num2 is declared as ByVal
    '  Passed  arguements a,b  :  a=10, b=20
    ' Returing values :   a=100, b=20
    ' because a=num1 (here num1 is ByRef) , b=num2  (here num2 is ByVal)
    '‘*********************************************************************
    a=10
    b=20
    msgbox Demo_PassingArgs4(a,b)
    msgbox a
    msgbox b

    Function Demo_PassingArgs4(ByRef num1,ByVal num2)
       num1=100
       num2=200
        Demo_PassingArgs4=num1+num2
    End Function