标题: 求助QTP的vbs脚本报错原因? [打印本页] 作者: fly_0307 时间: 2009-12-30 14:23 标题: 求助QTP的vbs脚本报错原因? 我是新手,下面是自己试写的一段代码,功能是遍历c:\test下所有名为wow.txt的脚本,包括子目录。找到后,以msgbox方式弹出。但执行时,报类型不匹配,请大家帮忙看看原因。
Function pathFind(searchingFolder,searchingFileName,fileType)
tempArray = Split (searchingFileName,".")
fileName = tempArray(0)&"."&fileType
MsgBox (tempArray(0))
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFolder = fso.GetFolder(searchingFolder)
Set objFileCollection = objFolder.Files
For Each objFile In objFileCollection
If objFile.Name = fileName Then
i=i+1
searchedFilePath(i) = objFile.Path
End If
Next
For m=1 To i
MsgBox (searchedFilePath(i)&Chr(10))
Next
Set objSubFoldersCollection = objFolder.SubFolders
For Each objInputSubFolder In objSubFoldersCollection
searchFilePath1 = pathFind(objInputSubFolder,seachingFileName,fileType)
Next
For n=1 To i
pathFind(n) = searchedFilePath(n)
Next
End Function
Call pathFind("C:\test","wow.txt","txt")作者: May_may 时间: 2009-12-30 15:09
searchedFilePath是数组,但之前没有定义长度,所以类型不匹配了吧