在本程序文件夹有cc.txt 
书写格式为 
5678909,346 
8793456,780 
2345446,567 
 现在要 s=? 读取每一行的“,”前面的数 
d=?读取每一行得“,”后面的数 
大概就像读取list里的一样 
for i=0 to List1.ListCount - 1 
s=List1.List(i)
我现在写成了
Private Sub Command1_Click() 
Dim i As Integer 
Dim dd() As String 
Dim s As String 
Dim Str As String Open App.Path & "\cc.txt" For Input As #1 
Do While Not EOF(1) 
Line Input #1, Str 
str1 = Split(Str, ",") 
str2 = str1(0)  
str3 = str1(1)
Loop 
Close #1 
List1.AddItem str3 End Sub 
只能输出最后一行,我要的是cc.txt有多少行数据,list里就有多少行数据,麻烦老师给看看

解决方案 »

  1.   

    应该把List1.AddItem str3放到循环内部 
      

  2.   

    Option ExplicitPrivate Sub Command1_Click()
            'Dim i As Integer
            Dim dd() As String
            'Dim s As String
            Dim Str As String
            
            Open "C:\Txt\TxtData.txt" For Input As #1
            Do While Not EOF(1)
               Line Input #1, Str
               dd = Split(Str, ",")
               List1.AddItem dd(0) & "," & dd(1)
            Loop
            Close #1
            
    End Sub
      

  3.   

    楼上正解   注意split中的符号,中英文不同