在文本文件中有一行以冒号(:)分隔的文字,多个冒号分隔, 怎样写代码将每个冒号之间的文本分别提取出来,并计算出有多少个?该行以字符型开头,然后冒号间隔,最后以分号结尾。
例如:
   文本是:
   10::YUANHUA:CN:VOYAGE:::1999021:19990215::QD::NB'谢谢指教?

解决方案 »

  1.   

    可以用instr这个函数循环来找,不过会麻烦一点.
      

  2.   

    利用循环,从头到尾或者从尾到头在字符串中取子字符串。主要的函数
       InStr  用来查找分隔符的位置
       Mid    用来获得指定位置和长度的字符串
      

  3.   

    用split(string,":")
    返回字符串数组,数组元素就是用 “:”分割的文本
      

  4.   

    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)