vb问题(把文本中的每行内容存放在数组中)
PrivateSubCommand2_Click()DimiAsLongdimb()asstringDimaAsStringCommonDialog1.Filter="文...
Private Sub Command2_Click()
Dim i As Long
dim b() as string
Dim a As String
CommonDialog1.Filter = "文本文件(*.txt)|*.txt"
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, a
b(i) = a
i = i + 1
Loop
Close #1
End Sub
我的目的是将一个文本文件中的每行内容存放到一个数组中。在运行的过程中总是提示下标越界。求高手指点,该怎么修改才可以实现这个功能,急,在线等。。。。 展开
Dim i As Long
dim b() as string
Dim a As String
CommonDialog1.Filter = "文本文件(*.txt)|*.txt"
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, a
b(i) = a
i = i + 1
Loop
Close #1
End Sub
我的目的是将一个文本文件中的每行内容存放到一个数组中。在运行的过程中总是提示下标越界。求高手指点,该怎么修改才可以实现这个功能,急,在线等。。。。 展开
2个回答
展开全部
Private Sub Command2_Click()
Dim i As Long
i=1
dim b() as string
Dim a As String
CommonDialog1.Filter = "文本文件(*.txt)|*.txt"
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, a
redim preserve b(1 to i)
b(i) = a
i = i + 1
Loop
Close #1
End Sub
Dim i As Long
i=1
dim b() as string
Dim a As String
CommonDialog1.Filter = "文本文件(*.txt)|*.txt"
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1
Do While Not EOF(1)
Line Input #1, a
redim preserve b(1 to i)
b(i) = a
i = i + 1
Loop
Close #1
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询