SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Aug 2004
    Location
    Delhi, India
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Use return value in another function

    How to use return value of a function in another function in QTP.
    Sumit Rathi

  2. #2
    Advanced Member RKY's Avatar
    Join Date
    Aug 2006
    Location
    Hyderabad, India
    Posts
    586
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Use return value in another function


    bResult = Call Sample("5")
    Msgbox "Return value of Sample function " & bResult
    <font class="small">Code:</font><hr /><pre>
    Function Sample(InParameter)
    Sample = InParameter
    End Function
    </pre><hr />

    I would suggest you to have a look in to the VBScript help files before attempt.

  3. #3
    Super Member
    Join Date
    Sep 2007
    Location
    Chennai, Tamil nadu, India
    Posts
    1,003
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Use return value in another function

    It should be written like below

    bResult = Sample("5")
    Msgbox "Return value of Sample function " &amp; bResult
    <font class="small">Code:</font><hr /><pre>
    Function Sample(InParameter)
    Sample = InParameter
    End Function
    </pre><hr />
    i have never seen bugs sleeping

  4. #4
    Advanced Member
    Join Date
    Mar 2007
    Location
    Salt Lake City, UT, USA
    Posts
    606
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Use return value in another function

    Each function can be set up to return a value. Your calling script can store that value into a variable that you can use elsewhere (like I do below with x, y, z, and q, or you can use it in other ways, such as nesting one function inside another like I do below with the first line of code:

    <font class="small">Code:</font><hr /><pre>msgbox fTranslate(fMultiply(fAdd(2))) 'Twenty
    '
    x = fAdd(3)
    y = fMultiply(x)
    z = fTranslate(y)
    msgbox z 'Twenty Four
    '
    q = fTranslate(fMultiply(fAdd(4)))
    msgbox q 'I Cannot Translate 28
    '
    Function fAdd(inNumber)
    fAdd = inNumber +3
    End Function
    '
    Function fMultiply(inNumber)
    fMultiply = inNumber*4
    End Function

    Function fTranslate(inNumber)
    If inNumber = 20 Then
    fTranslate = "Twenty"
    ElseIf inNumber = 24 Then
    fTranslate = "Twenty Four"
    Else
    fTranslate = "I cannot translate " &amp; inNumber
    End If
    End Function</pre><hr />

    Hope that helps.
    "The last 10% of any software project will take 90% of the budgeted time. The first 90% will take the other 90%"

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.00%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 04:05 AM.

Copyright BetaSoft Inc.