在vbs中,利用Scripting.FileSystemObject对象的skipline方法,readline方法,再加上mid函数,可以轻松实现读取文件的指定内容:
Function GetStr(strFile,intRow,intCol)
With CreateObject("Scripting.FileSystemObject").OpenTextFile(strFile)
For i = 1 To intRow - 1
.skipline
Next
strTmp = .readline
GetStr = Mid(strTmp,intCol,1)
End With
End Function
对于读取文件内容到二维数组,你可以使用ADO来实现。
In VBS, you can easily achieve reading specified content of a file by using the skipline method, readline method of the Scripting.FileSystemObject object and the Mid function:
Function GetStr(strFile,intRow,intCol)
With CreateObject("Scripting.FileSystemObject").OpenTextFile(strFile)
For i = 1 To intRow - 1
.skipline
Next
strTmp = .readline
GetStr = Mid(strTmp,intCol,1)
End With
End Function
For reading file content into a two-dimensional array, you can use ADO to implement.