冒泡排序???4.1请问问题出在哪
运行不出结果,全是00000000000000
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, M
Text1.Text = ""
For i = 0 To 9
N:
'弹出提示对话框输入数字
M = InputBox("请输入排序的10个数字,这是第" & CStr(i + 1) & "个", "提示", "")
If IsNumeric(i) Then
a(i) = M
Else
MsgBox "请输入数字", vbOKOnly, "错误"
GoTo N
End If
Next i
End Sub