📄 form0615.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "学生成绩排名"
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "结束"
Height = 495
Left = 2880
TabIndex = 1
Top = 2400
Width = 975
End
Begin VB.CommandButton Command1
Caption = "排名"
Height = 495
Left = 1320
TabIndex = 0
Top = 2400
Width = 1095
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Option Base 1
Private Sub Command1_Click()
'单击排名按钮
Dim Student
Dim Score(5) As Single
Dim i As Integer, j As Integer
'输入学生姓名
Student = Array("李小明", "王强", "赵雷", "陈敏", "袁成")
'输入学生成绩
Score(1) = 98: Score(2) = 82: Score(3) = 76: Score(4) = 66: Score(5) = 75
Call Sort(Score, Student)
For i = 1 To 5
Print i, Student(i), Score(i)
Next i
End Sub
Private Sub Sort(a() As Single, b As Variant)
'排序子过程
Dim n As Integer, Max As Integer
Dim i As Integer, j As Integer
Dim Temp1 As Integer, Temp2 As String
n = UBound(a)
For i = 1 To n - 1
Max = i
For j = i + 1 To n
If a(Max) < a(j) Then
Max = j
End If
Next j
Temp1 = a(i) ' 交换数据
a(i) = a(Max)
a(Max) = Temp1
Temp2 = b(i)
b(i) = b(Max)
b(Max) = Temp2
Next i
End Sub
Private Sub Command2_Click()
'单击结束按钮
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -