VB下标越界怎么改?
PrivateSubCommand1_Click()DimiAsIntegerDims(100)AsByteOpen"C:\OutPut.dat"ForBinaryAs#...
Private Sub Command1_Click()
Dim i As Integer
Dim s(100) As Byte
Open "C:\OutPut.dat" For Binary As #1
i = 1
Do While Not EOF(1) '如果没读到最后一行则循环
Get #1, i, s(i)
i = i + 1
Loop
Close #1
Print s(2)
End Sub 展开
Dim i As Integer
Dim s(100) As Byte
Open "C:\OutPut.dat" For Binary As #1
i = 1
Do While Not EOF(1) '如果没读到最后一行则循环
Get #1, i, s(i)
i = i + 1
Loop
Close #1
Print s(2)
End Sub 展开
3个回答
展开全部
Private Sub Command1_Click()
Dim a(1 To 10) As Integer,i as integer,sum as integer,aver as float
Sum = 0
For i = 1 To 10
a(i) = Rnd * 100 + 1
Sum = Sum + a(i)
Next i
'此时i=11了,下面不越界才怪
aver= Sum / 10
Text1.Text=aver
for i = 1 To 10
If a(i) > aver Then
Print a(i)
End If
next i
End Sub
求采纳为满意回答。
Dim a(1 To 10) As Integer,i as integer,sum as integer,aver as float
Sum = 0
For i = 1 To 10
a(i) = Rnd * 100 + 1
Sum = Sum + a(i)
Next i
'此时i=11了,下面不越界才怪
aver= Sum / 10
Text1.Text=aver
for i = 1 To 10
If a(i) > aver Then
Print a(i)
End If
next i
End Sub
求采纳为满意回答。
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-09-01
展开全部
Private Sub Command1_Click()
Dim i As Integer
Dim s(100) As Byte
Open "C:\OutPut.dat" For Binary As #1
i = 1
Do While Not EOF(1) '如果没读到最后一行则循环
Get #1, i, s(i)
i = i + 1
if i =101 then exit do
Loop
Close #1
Print s(2)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim i As Integer
Dim s() As Byte
Open "C:\OutPut.dat" For Binary As #1
i = 1
Do While Not EOF(1) '如果没读到最后一行则循环
Redim Preserve s(i)
Get #1, i, s(i)
i = i + 1
Loop
Close #1
Print s(2)
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询