文本文件内容:
111
222
333
#下面不读入
444
555
666
777
#上面的不读入
888
999
000用Open "aaa.txt" For Output As #1
按顺序读到text(i).text 文本框内  即
text1.text= 111 (指窗体上显示的值)
text2.text= 222 (指窗体上显示的值)
text3.text= 333 (指窗体上显示的值)
text4.text= 888 (指窗体上显示的值)
text5.text= 999 (指窗体上显示的值)
text6.text= 000 (指窗体上显示的值)
Close #1要求两个有#的行中间的内容读入到combobox里去  即,444,555,666,777会被additem为combo1里.请问这个如何解决

解决方案 »

  1.   

    设一个 Boolean 变量,每读到行首为 # 就将该变量置反,其它的行就根据该变量的值决定释放添加到 ComboBox 中。
      

  2.   

    Tiger_Zhao 可不可以详细一点,
    给个代码什么的,偶还处于VB入门型的,讲的太深奥,偶听不太懂啊
      

  3.   

    dim s as string
    dim h as long
    dim i as long,idx as long
    dim tmp
    dim b as boolean'一次性读出文本内容到变量s中:
    h=freefile
    open app.path &"\aaa.txt" for binary as h
        s=space(lof(h))
        get #h,,s
    close'按回车符分组处理
    tmp=split(s,vbcrlf)
    for i=0 to ubound(tmp)
        if trim(tmp(i))<>"" and left(tmp(i),1)<>"#" then
            if b=false then
                text1(idx)=tmp(i)
                idx =idx+1
            else
                combo1.additem tmp(i)
            end if
        elseif left(tmp(i),1)="#" then
            b=not b
        end if

    next
                大概最直接的思路就是这样,没测试
      

  4.   

    dim hFile as integer, bFlag as boolean, sLine as string
    hFile = freefile()
    open "..." for input access read as #hfile
    while not eof(hfile)
        line input Ehfile, sLine
        if left(sline,1) = "#" then
            bFlag = Not bFlag 
        else
            if bFlag then combo1.additem sLine
        end if
    wend
    close #hfile
      

  5.   

    dim Strtmp as string
    dim flag1 as boolean
    dim i as longOpen "aaa.txt" For Output As #1 
    i=1
    flag1=false
    Do While Not EOF(1)
        Line Input #1, Strtmp
        if Strtmp="#"  then
           if  flag1=false then
               flag1=true    
           else
              flag1=false    
           end if
        else
            if flag1=false then
                 text(i).text=Strtmp    
             end if    
        end if       
    Loop
      

  6.   

    忘了i+1dim Strtmp as string 
    dim flag1 as boolean 
    dim i as long Open "aaa.txt" For Output As #1 
    i=1 
    flag1=false 
    Do While Not EOF(1) 
        Line Input #1, Strtmp 
        if Strtmp="#"  then 
          if  flag1=false then 
              flag1=true    
          else 
              flag1=false    
          end if 
        else 
            if flag1=false then 
                text(i).text=Strtmp    
                i=i+1
            end if    
        end if      
    Loop