Header Ads

QTP Assignment work on Funtion

Today I was planing to write something on QTP Assignments....
To start with..

Write a small function that with print some text.

The structure of a function is

Function Function_name
..........
lines of code
End Function


So the function would be
Function printline
msgbox "animesh"
End Function

If you have written this on your own...good..

Now write one function that will take value from user and send it to this function for printing.

So now it will be a calling and called function concept. The first function will take value from user and call the second function with a paarameter by which it will pass the value to the second function viz the called function.


Call catchvalue
Calling Function:
----------------------
Function catchvalue
input=inputbox("Enter some value")
f=printline(input)
End Function
Called Function:
-------------------------------
Function printline(c)
msgbox c
End Function

c is the argument of the function printline.

3.Now let us do it 5 times...

simple..
it will a for loop...like
for i=1 to 5
Call catchvalue

next

Calling Function:
----------------------
Function catchvalue
input=inputbox("Enter some value")
f=printline(input)
End Function
Called Function:
-------------------------------
Function printline(c)
msgbox c
End Function

4.Now let us do it n times...n will specified by user
 
input1=inputbox("Enter some iteration value")


 for i=1 to input1
Call catchvalue
next
Calling Function:
----------------------
Function catchvalue
input=inputbox("Enter some value")
f=printline(input)
End Function
Called Function:
-------------------------------
Function printline(c)
msgbox c
End Function

5. now let us make it such a way that it will work for all positive no but if other input is given then it will ask again for input.
Powered by Blogger.