📄 practice7_7.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3600
ClientLeft = 60
ClientTop = 345
ClientWidth = 7200
LinkTopic = "Form1"
ScaleHeight = 3600
ScaleWidth = 7200
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text3
Height = 735
Left = 1560
MultiLine = -1 'True
ScrollBars = 1 'Horizontal
TabIndex = 5
Top = 2520
Width = 5295
End
Begin VB.CommandButton Command3
Caption = "插入:"
Height = 495
Left = 240
TabIndex = 4
Top = 2640
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "排序:"
Height = 495
Left = 240
TabIndex = 3
Top = 1680
Width = 1215
End
Begin VB.TextBox Text2
Height = 735
Left = 1560
MultiLine = -1 'True
ScrollBars = 1 'Horizontal
TabIndex = 2
Top = 1560
Width = 5295
End
Begin VB.TextBox Text1
Height = 855
Left = 1560
MultiLine = -1 'True
ScrollBars = 1 'Horizontal
TabIndex = 1
Top = 360
Width = 5295
End
Begin VB.CommandButton Command1
Caption = "生成数据:"
Height = 495
Left = 240
TabIndex = 0
Top = 480
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim A() As Integer, n
Private Sub Command1_Click()
n = 20
ReDim A(1 To n)
Randomize
For i = 1 To n
A(i) = Int(Rnd * 50 + 1)
Text1.Text = Text1.Text & Str(A(i)) & Space(3)
Next i
End Sub
Private Sub Command2_Click()
For i = 1 To n - 1
For j = i + 1 To n
If A(i) < A(j) Then
t = A(i)
A(i) = A(j)
A(j) = t
End If
Next j
Next i
Text2.Text = ""
For i = 1 To n
Text2.Text = Text2.Text & Str(A(i)) & Space(3)
Next i
End Sub
Private Sub Command3_Click()
n = n + 1
ReDim Preserve A(1 To n)
num = Val(InputBox("请输入数字", "请输入数字", "0"))
For i = 1 To n - 1
If num > A(i) Then
For j = n To i + 1 Step -1
A(j) = A(j - 1)
Next j
A(i) = num
Exit For
End If
Next i
If num < A(n - 1) Then A(n) = num
Text3.Text = ""
For k = 1 To n
Text3.Text = Text3.Text & Str(A(k))
Next k
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -