入门到精通(数组10个数冒泡排序)请问大家,加粗的那行为什么不起作用呢
发表在VB图书答疑
2018-07-06
《Visual Basic开发实例大全·基础卷》第3章 数组与指针
是否精华
是
否
版块置顶:
是
否
Option Explicit
Dim a(9) As Long
Private Sub Command1_Click()
Dim i As Long, j As Long, b As Long
For i = 1 To 9
For j = 0 To 9 - i
If a(j) > a(j + 1) Then
b = a(j)
a(j) = a(j + 1)
a(j + 1) = b
End If
Next j
Next i
For i = 0 To 9
Text1.Text = Text1.Text + CStr(a(i)) + " "
If i=4 Then Text1.Text=Text1.Text+Chr(13)+Chr(10)
Next i
End Sub
Private Sub Command2_Click()
Dim i As Long, l
Text1.Text = ""
For i = 0 To 9
N:
l = InputBox("请输入排序的10个数字,这是第" & (i + 1) & "个", "提示", "")
If IsNumeric(l) Then
a(i) = l
Else
MsgBox "请输入数字", vbOKOnly, "错误"
GoTo N
End If
Next i
End Sub