vb 读取txt

2024-12-14 04:49:28
推荐回答(4个)
回答1:

open app.path "\cc.txt" for input #1
Do While Not EOF(1)
line input #1,str
str1=split(str,",") '得到每一行的
str2=str1(0) '得到,前面的数字
str3=str1(1) '得到.后台的数字
Loop
Close #1
------------------------------------------我晕
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) '得到.后台的数字
List1.AddItem str3 '这句放在这个位置
Loop
Close #1

回答2:

Dim i As Integer
Dim dd() As String
dim s as string
dim d as string

Open app.path "cc.txt" For Input As #1
Do While Not EOF(1)
Input #1, inp
dd = Split(inp, " ")
s= s & dd(0)
d= d & dd(1)
Loop
Close #1

回答3:

Dim strings As String
Dim d As String
Dim s As String
Dim i As Integer

Open Path For Input As #1
Do While Not EOF(1)
Line Input #1, strings
i = InStr(1, strings, ",", vbTextCompare)
s = Mid(strings, 1, i - 1)
d = Mid(strings, i + 1, Len(strings) - i)
Loop
Close (1)

回答4:

把 List1.AddItem str3 放到循环内!!!

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) '得到.后台的数字
List1.AddItem str3 '把这个放到循环内 就正确了。。。
Loop
Close #1