本文主要是介绍UFT基础_16作业讲解-切割字符串以及字典重构excel,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
'str ="页显示10条;每页显示20条;每页显示50条"'a = split(str,";")
'msgbox a(2)
'
'
''显示数组长度
'msgbox ubound(a)
'function excel将excel中指定sheet中的行数写到数组中,并返回数组。
Function excel(path,sheet)
Dim Arr()
Set ExcelApp= CreateObject( "Excel.Application")
Set objDic = CreateObject( "Scripting.Dictionary")
Set ExcelPath=ExcelApp.Workbooks.Open(path)
Set ExcelSheet=ExcelPath.Worksheets(sheet).UsedRange
rowCount=ExcelSheet.Rows.count
columnCount=ExcelSheet.Columns.count
For j = 1 To columnCount
For i = 1 To rowCount
ReDim preserve Arr(i- 1)
Arr(i- 1)=ExcelSheet.cells(i,j)
Next
ObjDic.Add j,Arr
Next
' b= objDic.Item(2)
' msgbox b(0)
Set ExcelSheet= NOthing
ExcelPath.Close
ExcelApp.Quit
Set excel = objDic
End Function
'//调用函数
Set b = excel( "D:\UFT\uft_16\data.xlsx", "sheet1")
m=b.item( 1)
msgbox ubound(m)
For i = 0 To ubound(m)
msgbox m(i)
Next
'msgbox ubound (b)
'msgbox b(0)
'For i = 1 To ubound(b)
' msgbox b(i)
'Next
'
Set fromCity =Wpfwindow( "HPE MyFlight Sample Applicatio").WpfComboBox( "fromCity")
For i = 0 To fromCity.GetItemsCount - 1
If fromCity.GetItem(i)=m(i) Then
print i& " is right"
else
print i& " is wrong"
End If
Next
这篇关于UFT基础_16作业讲解-切割字符串以及字典重构excel的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!