• 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 can be passed as
    ·         Pass ByValue
    ·         Pass ByReference
    Represented as
            ByRef
            ByVal

    Description about ByVal:
    Indicates that the argument is passed by value.
    Description about ByRef :
    Indicates that the argument is passed by reference.

    Note:By default all arguments are 'ByRef'.
       
    ·         ByRef explains that the value which is assigned to the variable within the function is permanent and we can use that value outside of that function too
    ·         It references the function and corresponding value assigned within the function
    ·         ByVal explains that the value which is assigned to the variable within the function is temporary and we can use that value only within that function.
    ·         It references the value assigned outside of the function

    Examples:
    ' 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 ( a=num1, b=num2 ; both 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  --.> both are declared as ByRef 
    '  Passed  arguements a,b     : a=10, b=20
    ' Returing values : a=100, b=200 ( a=num1, b=num2 ; both 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 ( a=num1, b=num2 ; both 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( a=num1 (num1 is ByRef) , b=num2  ( 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 - Argument types

    Arguments can be passed as
    ·         Pass ByValue
    ·         Pass ByReference
    Represented as
            ByRef
            ByVal

    Description about ByVal:
    Indicates that the argument is passed by value.
    Description about ByRef :
    Indicates that the argument is passed by reference.

    Note:By default all arguments are 'ByRef'.
       
    ·         ByRef explains that the value which is assigned to the variable within the function is permanent and we can use that value outside of that function too
    ·         It references the function and corresponding value assigned within the function
    ·         ByVal explains that the value which is assigned to the variable within the function is temporary and we can use that value only within that function.
    ·         It references the value assigned outside of the function

    Examples:
    ' 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 ( a=num1, b=num2 ; both 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  --.> both are declared as ByRef 
    '  Passed  arguements a,b     : a=10, b=20
    ' Returing values : a=100, b=200 ( a=num1, b=num2 ; both 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 ( a=num1, b=num2 ; both 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( a=num1 (num1 is ByRef) , b=num2  ( 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