Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VBScript - How to get the Function return value
#2
Solved: 11 Years, 4 Months, 3 Weeks ago
Hi

Two Ways:

Code:
Function GetRowCount(fileName)
SwfWindow("Lilly Science Grid").Dialog("File Download").Click 285,18
SwfWindow("Lilly Science Grid").Dialog("File Download").Activate
SwfWindow("Lilly Science Grid").Dialog("File Download").WinButton("Save").Click
Dialog("Save As").Activate
Dialog("Save As").WinEdit("File name:").Set "D:\SaveXlsFile.xls"
Dialog("Save As").WinButton("Save").Click
Dialog("Save As_2").WinButton("Yes").Click
'Dialog("Download complete").Click 321,184
'Dialog("Download complete").WinButton("Close").Click

Set xlObj = CreateObject ("Excel.Application") ' Create Excel object
Set wBook = xlObj.workBooks.Open(fileName) ' Pass file name
Set sheetName = wBook.worksheets("Sheet1") ' Pass default sheet name
row_count = sheetName.usedrange.rows.count -1' 'Return total number of rows
[b]GetRowCount=row_count[/b]
End Function

retFunc = GetRowCount( fileName) // Function calling
retFunc will store the value and you can use this in your script.

2nd Approach:
Code:
Function GetRowCount(BYVal convLng , fileName)
SwfWindow("Lilly Science Grid").Dialog("File Download").Click 285,18
SwfWindow("Lilly Science Grid").Dialog("File Download").Activate
SwfWindow("Lilly Science Grid").Dialog("File Download").WinButton("Save").Click
Dialog("Save As").Activate
Dialog("Save As").WinEdit("File name:").Set "D:\SaveXlsFile.xls"
Dialog("Save As").WinButton("Save").Click
Dialog("Save As_2").WinButton("Yes").Click
'Dialog("Download complete").Click 321,184
'Dialog("Download complete").WinButton("Close").Click

Set xlObj = CreateObject ("Excel.Application") ' Create Excel object
Set wBook = xlObj.workBooks.Open(fileName) ' Pass file name
Set sheetName = wBook.worksheets("Sheet1") ' Pass default sheet name
[b]convLng [/b]= sheetName.usedrange.rows.count -1' 'Return total number of rows
End Function

Then Use the convLng variable in your code.

Do let me know if you have any other question.
Reply


Messages In This Thread
RE: VBScript - How to get the Function return value - by QTPLearn - 09-08-2010, 02:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Childobject return wrong checkbox count.. VpnQTP 1 2,890 04-09-2015, 09:07 PM
Last Post: babu123
  Calling a Function in Function Library when function is defined in an Action jitenderkkr 0 3,036 11-27-2014, 12:53 PM
Last Post: jitenderkkr
  SQL on oracle database doesn't return a value Bluefields 2 3,336 07-09-2012, 01:23 PM
Last Post: Bluefields
  Return reusable object HelenN 0 4,409 04-20-2011, 08:31 PM
Last Post: HelenN
  Calling a JS function which is externally located using a VBScript Func in QTP HishSingalaxana 0 2,993 11-09-2010, 11:02 AM
Last Post: HishSingalaxana

Forum Jump:


Users browsing this thread: 1 Guest(s)