Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to pass 2 arguments to a function
#1
Solved: 11 Years, 4 Months ago
I have created a function for string comaprison in .vbs file
The function looks like this and i am getting the return value
Code:
Public function StringCom(x1,x2)
Dim getvalue
getvalue =StrComp(x1,x2,compare)
StringCom =getvalue
End function

Now i call this function in QTP
Code:
dim x
x1 = "abc"
x2 = "abcdef"
x =Call StringCom (x1, x2)
msgbox x

here x should display the return value from the function

When i run this function in qtp, i get the following error message- Type msimatch StringCom

Can anybody please provide the right code
Reply
#2
Solved: 11 Years, 4 Months ago
Dear Rashmi,
Your code is fine except calling the function.
You don need to use the call statement.
so instead of this line
Code:
x =Call StringCom (x1, x2)

use
Code:
x = StringCom(x1,x2)

The function is returning so you just need catch the return value into a variable by using the name of the function and parameters.

I Would Recommend you to go through the link and learn VB Script

http://www.w3schools.com/vbscript/default.asp

Hope this is going to be helpful for you.
Reply
#3
Solved: 11 Years, 4 Months ago
Thanks for the quick response.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calling a function in a Test Script from a function library anupam4j 3 6,114 06-26-2015, 12:31 AM
Last Post: babu123
  PASS/FAIL in QTP badri 3 6,199 12-05-2014, 03:26 AM
Last Post: kiranpol
  how to pass the data frm datatable silpavinod 3 3,952 10-18-2012, 01:54 PM
Last Post: silpavinod
  How to pass all rows from data sheet in a function argument richa07 1 3,064 10-15-2012, 03:06 PM
Last Post: srinath_QTP
  how to pass a numeric value into webedit silpavinod 3 3,863 10-15-2012, 01:57 PM
Last Post: silpavinod

Forum Jump:


Users browsing this thread: 1 Guest(s)