dim fso as new filesystemobject dim txt as textstream dim str as string dim strResult() as string dim Count as integer'打开文件,读取字符串 set txt=fso.opentextfile(文件名) str=txt.readline'分割字符串 strResult=split(str,":") '计算有多少个文本段 Count=ubound(strResult)+1 '最后一个去掉'号 strResult(Ubound)=left(strResult(Ubound),len(strResult(Ubound))-1)
InStr 用来查找分隔符的位置
Mid 用来获得指定位置和长度的字符串
返回字符串数组,数组元素就是用 “:”分割的文本
dim txt as textstream
dim str as string
dim strResult() as string
dim Count as integer'打开文件,读取字符串
set txt=fso.opentextfile(文件名)
str=txt.readline'分割字符串
strResult=split(str,":")
'计算有多少个文本段
Count=ubound(strResult)+1
'最后一个去掉'号
strResult(Ubound)=left(strResult(Ubound),len(strResult(Ubound))-1)