Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
VBScript - How to get the Function return value
#1
Solved: 10 Years, 9 Months ago
Hi All,
I have scenario like
1. i am passing value (rowCnt) and file name (fileName) to the function
2. Inside Function i am reading xls file and getting some row count (row_count)
3. In side the function i can able to compare rowCnt = row_count by using reporter.ReportEvent

My question is: I want to do use "reporter.ReportEvent" out side the function.
4. How to write if condition inside function to satisfy my scenario.

Code:
Window("Lilly Science Grid").Page("Page_3").Link("25").Click
rowCnt = Window("Lilly Science Grid").Page("Page_3").Link("25").GetROProperty("text") '
convLng = CLng(rowCnt) ' Convert to String to Long
[b]retFunc = GetRowCount(convLng, fileName) [/b] // Function calling

fileName = "D:\SaveXlsFile.xls"

[b]Function GetRowCount(convLng,fileName)[/b]
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

If row_count  = convLng Then
// I want to write below code out side the function but i have to validate [b]if condition here only (If row_count  = convLng )[/b][b]
    reporter.ReportEvent micPass, "Row Count Validation","Row Count matching with column header. Step.Pass"
    else
    reporter.ReportEvent micFail, "Row Count Validation","Row Count is not matching with column header.Step.Fail"
End If
wBook.close
End Function

Kindly suggest how to approach [/b]and i will appreciate your help
Reply


Messages In This Thread
VBScript - How to get the Function return value - by iamsekhar - 09-08-2010, 12:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Childobject return wrong checkbox count.. VpnQTP 1 2,570 04-09-2015, 09:07 PM
Last Post: babu123
  Calling a Function in Function Library when function is defined in an Action jitenderkkr 0 2,777 11-27-2014, 12:53 PM
Last Post: jitenderkkr
  SQL on oracle database doesn't return a value Bluefields 2 3,062 07-09-2012, 01:23 PM
Last Post: Bluefields
  Return reusable object HelenN 0 4,203 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,843 11-09-2010, 11:02 AM
Last Post: HishSingalaxana

Forum Jump:


Users browsing this thread: 2 Guest(s)