【VB开源代码栏目提醒】:以下是网学会员为您推荐的VB开源代码-5.8.2.frm,希望本篇文章对您学习有所帮助。
VERSION 5.00
Begin VB.Form Form9
Caption = "Form9"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form9"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
End
Attribute VB_Name = "Form9"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub xzPaiXu(a() As Integer)
'a为需要排序的数组列
Dim i As Integer
Dim j As Integer
Dim temp As Integer
Dim m As Integer
For i = LBound(a) To UBound(a) - 1
'进行数组大小-1轮比较
m = i
'在第i轮比较时,假定第i个元素为最值元素
For j = i + 1 To UBound(a)
'在剩下的元素中找出最值元素的下标并记录在m中下标,否则记录最大元素下标
If a(j) < a(m) Then
m = j
End If
Next j
'将最值元素与第i个元素交换
temp = a(i)
a(i) = a(m)
a(m) = temp
Next i
End Sub
Private Sub Form_Click()
Dim b(5) As Integer
Dim i As Integer
For i = 1 To 5
b(i) = InputBox("请输入第" & i & "个元素的值", "输入")
Next i
Call xzPaiXu(b)
For i = 1 To 5
Print b(i);
Next
End Sub
上一篇:
5.8.1.frm
下一篇:
"夜"