vb编程,大佬看下哪里错了?
PrivateSubCommand1_Click()list1=""Dima(10)AsIntegerDimXAsIntegerX=Val(Text1.Text)list...
Private Sub Command1_Click()
list1 = ""
Dim a(10) As Integer
Dim X As Integer
X = Val(Text1.Text)
list1.Clear
list2.Clear
a(1) = 7: a(2) = 10: a(3) = 13: a(4) = 16: a(5) = 19
For i = 1 To 5
list1.AddItem Str(a(i))
Next i
i = 5
Do While a(i) > X
a(i + 1) = a(i)
i = i - 1
Loop
a(i + 1) = X
For i = 1 To 6
list2.AddItem Str(a(i))
Next i
End Sub 展开
list1 = ""
Dim a(10) As Integer
Dim X As Integer
X = Val(Text1.Text)
list1.Clear
list2.Clear
a(1) = 7: a(2) = 10: a(3) = 13: a(4) = 16: a(5) = 19
For i = 1 To 5
list1.AddItem Str(a(i))
Next i
i = 5
Do While a(i) > X
a(i + 1) = a(i)
i = i - 1
Loop
a(i + 1) = X
For i = 1 To 6
list2.AddItem Str(a(i))
Next i
End Sub 展开
展开全部
楼主没有把问题的要求说明清楚,现在只能检查语法上的问题。
其实代码本身没有语法错误。这程序代码是把文本框中输入的数,插入到一个有序数组中,使数组依然保持有序。
只要补全代码中需要的四个控件(一个命令按钮、两个列表框、一个文本框),就可以正确运行程序了:
Private Sub Command1_Click()
List1 = ""
Dim a(10) As Integer
Dim X As Integer
X = Val(Text1.Text)
List1.Clear
List2.Clear
a(1) = 7: a(2) = 10: a(3) = 13: a(4) = 16: a(5) = 19
For i = 1 To 5
List1.AddItem Str(a(i))
Next i
i = 5
Do While a(i) > X
a(i + 1) = a(i)
i = i - 1
Loop
a(i + 1) = X
For i = 1 To 6
List2.AddItem Str(a(i))
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询