循环从txt,excel文件中读取数据进行飞机订票系统(完成从txt读数据)
上一篇 /
下一篇 2011-09-13 10:10:44
'txt读取文件
Dim fso,myfile,tmp,username,passwd,mychar
Set fso = createobject("scripting.filesystemobject")
Set myfile = fso.OpenTextFile("c:\cc.txt",1,false)
Do until myfile.AtEndOfLine
' mychar = myfile.ReadLine
tmp = split(myfile.ReadLine,",")
username = tmp(0)
passwd = tmp(1)
' msgbox username
' msgbox passwd
systemutil.Run("D:\QTP_HP\QuickTest Professional\samples\flight\app\flight4a.exe")
dialog("Login").WinEdit("Agent Name:").Set tmp(0)
dialog("Login").WinEdit("Password:").Set tmp(1)
wait(2)
dialog("Login").WinButton("Cancel").Click
Loop
myfile.Close
'excel文件读取
Option Explicit
Dim i,j,rowcount,columncount,filePath
Dim ExcelBook,ExcelSheet,myExcelbook,myExcelSheet
filePath = "C:\cc.xls"
Set ExcelBook = createobject("Excel.Application")
Set ExcelSheet = createobject("Excel.Sheet")
Set myExcelBook = ExcelBook.Workbooks.Open(filePath)
Set myExcelSheet = myExcelBook.Worksheets("Sheet1")
rowcount = myExcelSheet.UsedRange.Rows.count
columncount = myExcelSheet.UsedRange.Columns.count
For i =1 to rowcount
' For j=1 to columncount
systemutil.Run "D:\QTP_HP\QuickTest Professional\samples\flight\app\flight4a.exe"
Dialog("Login").WinEdit("Agent Name:").Set myExcelSheet.Cells(i,1)
Dialog("Login").WinEdit("Password:").Set myExcelSheet.Cells(i,2)
wait(2)
systemutil.CloseProcessByName("flight4a.exe")
' Next
Next
ExcelBook.Quit
Set ExcelBook = Nothing
收藏
举报
TAG: