dim a() as string
a=split(s," ")
for i=0 to Ubound(a)-1
  Write #1,a(i)
next

解决方案 »

  1.   

    呵呵,忘了加 step 5了循环用:
    For i=0 to ubound(a)-1 step 4
      Write #1,a(i) &" "&a(i+1) & " " & a(i+2) & " " & a(i+3) &" " & a(i+4)
    next
    close #1
      

  2.   

    你的意思是按照非数字拆分吧
    用ascii码值判断一下
      

  3.   

    tygh2000(峰)兄 的方法不对,你没弄清我的意思,你的方法是5个一行,我的问题里是不一定5个一行的。
      

  4.   

    0的ASCII码值为48,9的ASCII值为57 根据这个来判断
    dim n_first as integer 
    dim n_last as integer 
    dim n as long 
    n_first=0
    for n=0 to len(字符串)
       if n_first=0 and asc(mid(字符串,n+1,1))<48 or asc(mid(字符串,n+1,1))>57 then
         n_first=n
       elseif n_first=0 and asc(mid(字符串,n+1,1))<48 or asc(mid(字符串,n+1,1))>57 then
        n_last=n
        exit for
       end if
    next n
    得到两个英文字母的位置重新组合字符串其余的原理一样
      

  5.   

    可以用instr()找到"as","cy","gyg"的位置,然后用mid()取出字符串,再写到文本文件中。
      

  6.   

    "as","cy","gyg"只是随便写的,实际可能有很多都不同,所以不能一一找到,。
      

  7.   

    SORRY,我的回复有错误!试了一下,如果一个分字符串中有两个以上的英文字母就熄火了,取出来是错的
    还要再仔细考虑一下
    不过思路应该就是这样,要麻烦一点
      

  8.   

    先找到第一个非数字的值记录下位置,在找到第一个数字记录下位置,之后在查找第一个数字后面的非数字的值记录位置,另外要注意空格可以用mousean(幻想无限)提供的方法实现
      

  9.   

    利用Split函数,可以快速切分和拼接。Dim yourStr As String
    Dim Strs() As String
    Dim i As Integer
    Dim temp As StringyourStr = "as1234 23456 21080 00007 23456 cy2345 54321 21080 55155 12345 34213 gyg2349 23212 21080 55155 34527 77651"
    Strs = Split(yourStr, " ")
    temp = Strs(0)
    For i = 1 To UBound(Strs) - 1
    If Left(Strs(i), 1) > "9" Then
    List1.AddItem temp
    temp = Strs(i)
    Else
    temp = temp & " " & Strs(i)
    End If
    Next i
    List1.AddItem temp
      

  10.   

    上面的例子是用list控件显示结果。
    你可以改成写文本文件。
      

  11.   

    of123() 对的
    竟把Split函数给丢到脑后了
    :(!
      

  12.   

    恩,用split也可以实现,比较简单我的太麻烦了,呵呵
      

  13.   

    用下面的方法试试:
    先用split将字符串分开,再查找首位是字母的元素,然后重新联接
    Dim yourStr As String
    Dim Strs() As String
    Dim i As Integer
    Dim temp As String
    Dim tmp() As Integer,j as Integer
    Dim Result() as String,k as Integer
    yourStr = "as1234 23456 21080 00007 23456 cy2345 54321 21080 55155 12345 34213 gyg2349 23212 21080 55155 34527 77651"
    Strs = Split(yourStr, " ")
    j=0
    ReDim Preserve tmp(j) as Integer 
    tmp(0)=0'开始位置
    for i=0 to ubound(Strs)
       if asc(left$(Strs(i),1))>asc("9") then
         j=j+1
         ReDim Preserve tmp(j) as Integer '保留原有数据
         if i>0 then tmp(j)=i-1'记录位置,但不记录第一个位置
       end if
    next
    Redim Result(j) as string
    '重新组合
    for k=0 to ubound(tmp)-1
      for i=tmp(k) to tmp(k+1)
        Result(k)=Result(k) & Strs(i) & " "
      next
      print #1,Result(k)
    next
    for i=tmp(k) to ubound(Strs)
       Result(k)=Result(k) & Strs(i) & " "
    next
    print #1,Result(k)
      

  14.   

    刚才写错了一点,正确的如下
    Dim yourStr As String
    Dim Strs() As String
    Dim i As Integer
    Dim temp As String
    Dim tmp() As Integer,j as Integer
    Dim Result() as String,k as Integer
    yourStr = "as1234 23456 21080 00007 23456 cy2345 54321 21080 55155 12345 34213 gyg2349 23212 21080 55155 34527 77651"
    Strs = Split(yourStr, " ")
    j=0
    ReDim Preserve tmp(j) as Integer 
    tmp(0)=0'开始位置
    for i=1 to ubound(Strs)
       if asc(left$(Strs(i),1))>asc("9") then
         j=j+1
         ReDim Preserve tmp(j) as Integer '保留原有数据
         if i>0 then tmp(j)=i'记录位置,但不记录第一个位置
       end if
    next
    Redim Result(j) as string
    '重新组合
    for k=0 to ubound(tmp)-1
      for i=tmp(k) to tmp(k+1)-1
        Result(k)=Result(k) & Strs(i) & " "
      next
      print #1,Result(k)
    next
    for i=tmp(k) to ubound(Strs)
       Result(k)=Result(k) & Strs(i) & " "
    next
    print #1,Result(k)