qtp计算器脚本

时间:2015-09-23 14:12:13
【文件属性】:

文件名称:qtp计算器脚本

文件大小:15KB

文件格式:DOCX

更新时间:2015-09-23 14:12:13

计算器 qtp

读Excel文件中的计算式,调用计算器实现自动计算 【Dim aslen,t , iRowCount, iLoop, numAdd,xlApp, xlFile, xlSheet Set xlApp = CreateObject ("Excel.Application") Set xlFile = xlApp.Workbooks.Open ("c:\a.xlsx") Set xlSheet = xlFile.Sheets("Sheet1") iRowCount = xlSheet.usedRange.Rows.Count ‘计算Sheet1中已经填写的行数 For iLoop = 2 To iRowCount numAdd2 = xlSheet.Cells(iLoop,2) ‘读出Excel的第二列的内容 aslen=Len( numAdd2) For t=1 To aslen Select Case Mid(numAdd2,t,1) Case "1" Window("计算器").WinButton("1").Click Case "2" Window("计算器").WinButton("2").Click Case "3" Window("计算器").WinButton("3").Click Case "4" Window("计算器").WinButton("4").Click Case "5" Window("计算器").WinButton("5").Click Case "6" Window("计算器").WinButton("6").Click Case "7" Window("计算器").WinButton("7").Click Case "8" Window("计算器").WinButton("8").Click Case "9" Window("计算器").WinButton("9").Click Case "0" Window("计算器").WinButton("0").Click Case "+" Window("计算器").WinButton("+").Click Case "-" Window("计算器").WinButton("-").Click Case "*" Window("计算器").WinButton("*").Click Case "/" Window("计算器").WinButton("/").Click Case "=" Window("计算器").WinButton("=").Click Case "." Window("计算器").WinButton(".").Click Case "C" Window("计算器").WinButton("C").Click case else msgbox "input error" End Select Next Next Window("计算器").Close xlFile.Save xlFile.Close xlApp.Quit Set xlSheet = Nothing Set xlFile = Nothing Set xlApp = Nothing


网友评论