有一个1.DAT文件, 只有一行, 有很多列, 在VB中如何实现数据一一对应读入
例如数组如下
110 1400 0.25 350 0.35 1.8如何读入实现
A=110
B=1400
C=0.25
D=350
E=0.35
F=1.8我写了下面的代码,但只能提取第一个数110,不知那里有问题,大家帮我看一下Private Sub Command1_Click()
Dim strA(1) As String
Dim strRlt As Variant
Open "C:\1.DAT" For Input As #1
Line Input #1, strA(1)
Debug.Print strA(1)strRlt = Split(strA(1), " ")
a = strRlt(0)
b = strRlt(1)
c = strRlt(2)
d = strRlt(3)
e = strRlt(4)Print a, b, c, d, eClose
End Sub
例如数组如下
110 1400 0.25 350 0.35 1.8如何读入实现
A=110
B=1400
C=0.25
D=350
E=0.35
F=1.8我写了下面的代码,但只能提取第一个数110,不知那里有问题,大家帮我看一下Private Sub Command1_Click()
Dim strA(1) As String
Dim strRlt As Variant
Open "C:\1.DAT" For Input As #1
Line Input #1, strA(1)
Debug.Print strA(1)strRlt = Split(strA(1), " ")
a = strRlt(0)
b = strRlt(1)
c = strRlt(2)
d = strRlt(3)
e = strRlt(4)Print a, b, c, d, eClose
End Sub
Private Sub Command1_Click()
Dim strA As String
Dim strRlt() As Variant
Open "C:\1.DAT" For Input As #1
Line Input #1, strA
Debug.Print strAstrRlt = Split(strA, " ")
a = strRlt(0)
b = strRlt(1)
c = strRlt(2)
d = strRlt(3)
e = strRlt(4)Print a, b, c, d, eClose
End Sub
麻烦不麻烦啊!
a = s2(0)
b = s2(1)
c = s2(2)
d = s2(3)
e = s2(4)
就可以了,切割开来而已
不应该是用stra数组
Dim strA As String
Dim strRlt() As StringOpen "C:\1.DAT" For Input As #1
Line Input #1, strA
Close #1Debug.Print strADo While InStr(1, strA, Space(2))
strA = Replace(strA, Space(2), Space(1))
LoopstrRlt = Split(strA, Space(1))
a = strRlt(0)
b = strRlt(1)
c = strRlt(2)
d = strRlt(3)
e = strRlt(4)Print a, b, c, d, e
End Sub
dim a as byte,b as string
dim file_long as long,file_point as long
open "c:/1.dat" for binary as #1
file_long =lof(1)
do until file_point >file_long
get #1,file_point
if a<>32 then
b=b & chr$(a)
else
call out_data(b)
b=""
end if
loop
end sub
sub out_data(byval b as string)
'code here to change kind of b and print
debut.pring b
end sub