用VB如何把文本文件中的数字存入数值数组,请高手指点下。
如E盘的文本文件中有以下数字,每个数字两边都有两个逗号,用VB如何只读取数字,并把数字存入数值数组。,25,,30,,10,,23,,22,,31,,2,,2,,8,,1...
如E盘的文本文件中有以下数字,每个数字两边都有两个逗号,用VB如何只读取数字,并把数字存入数值数组。
,25,
,30,
,10,
,23,
,22,
,31,
,2,
,2,
,8,
,15,
,12,
,8,
,4,
,27,
,30,
,18, 展开
,25,
,30,
,10,
,23,
,22,
,31,
,2,
,2,
,8,
,15,
,12,
,8,
,4,
,27,
,30,
,18, 展开
2个回答
展开全部
不要用复制,可能会出错。一个一个打上去吧。半角字符。
dim aStr() as string
dim i as integer
set fso = createobject("scripting.filesystemobject")
set myText = fso.opentextfile("E:\123.txt",1)
i = 0
do until myText.atendofstream
redim preserve astr(i)
astr(i) = replace(myText.readline,",","")
i = i +1
loop
dim aStr() as string
dim i as integer
set fso = createobject("scripting.filesystemobject")
set myText = fso.opentextfile("E:\123.txt",1)
i = 0
do until myText.atendofstream
redim preserve astr(i)
astr(i) = replace(myText.readline,",","")
i = i +1
loop
展开全部
Private Sub Command1_Click()
Dim S As String
Dim A
Dim Ar() As Long
Open "E:\123.TXT" For Binary As #1
S = Replace(StrConv(InputB(LOF(1), 1), vbUnicode), ",", "")
Close #1
A = Split(S, vbCrLf)
ReDim Ar(UBound(A))
For I = 0 To UBOUIND(A)
Ar(I) = A(I)
Next
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询