📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4965
ClientLeft = 60
ClientTop = 450
ClientWidth = 7980
LinkTopic = "Form1"
ScaleHeight = 4965
ScaleWidth = 7980
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text2
Height = 1335
Left = 840
TabIndex = 3
Text = "Text2"
Top = 3120
Width = 3735
End
Begin VB.TextBox Text1
Height = 1455
Left = 840
TabIndex = 2
Text = "Text1"
Top = 720
Width = 3735
End
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 735
Left = 6000
TabIndex = 1
Top = 1920
Width = 1575
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 735
Left = 6000
TabIndex = 0
Top = 600
Width = 1575
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Dim a(20), r(10) As Integer
Dim b(10) As Variant
Sub insertsort(s()) '插入排序程序
Dim i, j
Dim TEMP
Dim gI
Dim t
t = 0
j = LBound(s) + 1
While (j <= UBound(s)) '不超出上界
i = j
Do
If i > LBound(s) Then '不超出下界
If s(i) < s(i - 1) Then
TEMP = s(i)
s(i) = s(i - 1)
s(i - 1) = TEMP
i = i - 1
Else
Exit Do
End If
Else
Exit Do
End If
gI = gI + 1
Loop
j = j + 1
t = i - 1
Call printf
Wend
End Sub
Public Sub printf()
result = ("第") + " " + Str$(t) + " " + ("趟")
Call xianshi
End Sub
Sub xianshi()
Dim j, k As Integer
For j = 1 To k
result = result + " " + Str$(r(j))
Next j
Text2.Text = result
End Sub
Private Sub Command1_Click()
Dim i As Integer
Dim textstr As String
For i = 0 To 9
b(i) = InputBox("请逐个输入待排序序列(10个):")
textstr = textstr + Str$(b(i)) + Space(1)
Text1.Text = textstr
Next i
End Sub
Private Sub Command2_Click()
Call insertsort(b)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -