Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to create a global variable in QTP
#1
Not Solved
Hi ,
I am facing a problem while creating script in QTP.
Please find below the code...

Code:
Function   RandomString( ByVal strLen )
    Dim str
    Const  LETTERS = "abcdefghijklmnopqrstuvwxyz0123456789"
   For i = 1 to strLen
     str = str & Mid( LETTERS, RandomNumber( 1, Len( LETTERS ) ), 1 )
    Next
  RandomString=str

End Function

'-----------*END FUNCTION*-----------------------
Code:
public a
a=RandomString(4)  'Put  random string generated into a variable 'a'
msgbox(a)
'------------*GET VALUE OF MFG PART# FROM G.SHEET  & SET  PRICE OUTPUT VALUE  in G.SHEET*-------------
row_cnt=datatable.getrowcount
for i=1 to row_cnt ' For each row , do following
datatable.getsheet(i) ' Read Sheet 1 i.e. Global sheet

datatable.Value("Asset_Id",1)=a
msgbox(a)

datatable.setnextrow ' Increment loop counter



Asset_Id is a column in my datasheet..
But still value of as is not getting saved in that column..donn know why..
I am doing record and play..

So please help me to solve this issue.
Reply


Messages In This Thread
How to create a global variable in QTP - by galstar - 08-04-2010, 04:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading Global Sheet's DataTable Value Bhuvana 0 1,639 01-05-2020, 10:03 PM
Last Post: Bhuvana
  Error as Global Not defined while trying to retrieve value from Datatable siddharth1609 0 965 09-11-2019, 02:52 PM
Last Post: siddharth1609
  cannot create java virtual machine on QTP 12.02 version richa5685 0 1,973 02-23-2016, 11:18 AM
Last Post: richa5685
  On Saving Script in QTP 11 my Global Data Sheet data is removed M Adnan Iftikhar 0 2,177 06-02-2015, 09:19 PM
Last Post: M Adnan Iftikhar
  global object which can be called in any action excellentpawan123 2 2,769 04-01-2015, 07:34 PM
Last Post: babu123

Forum Jump:


Users browsing this thread: 1 Guest(s)