📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
AutoRedraw = -1 'True
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 5115
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 5115
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command5
Caption = "删除"
Height = 495
Left = 3960
TabIndex = 3
Top = 2040
Width = 1095
End
Begin VB.CommandButton Command4
Caption = "数组排序"
Height = 495
Left = 3960
TabIndex = 2
Top = 840
Width = 1095
End
Begin VB.CommandButton Command3
Caption = "生成数组"
Height = 495
Left = 3960
TabIndex = 1
Top = 240
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "插入"
Height = 495
Left = 3960
TabIndex = 0
Top = 1440
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
Dim c%(), a%, b%
Private Sub Command1_Click()
Dim s%
s = Val(InputBox("请输入要插入的元素."))
a = UBound(c)
ReDim Preserve c(UBound(c) + 1)
While s < c(a) And a > 0
c(a + 1) = c(a)
a = a - 1
Wend
c(a + 1) = s
For a = 1 To UBound(c)
Print c(a);
If a = 10 Then Print
Next a
Print
End Sub
Private Sub Command3_Click()
Cls
Randomize
For a = 1 To 10
ReDim Preserve c%(a)
c(a) = Rnd * 99 + 1
Print c(a);
Next a
Print
End Sub
Private Sub Command4_Click()
Dim m%, l%
For a = 1 To UBound(c) - 1
l = a
For b = a + 1 To UBound(c)
If c(l) > c(b) Then
l = b
End If
Next b
If l <> a Then
m = c(l)
c(l) = c(a)
c(a) = m
l = l + 1
End If
Next a
For a = 1 To UBound(c)
Print c(a);
Next a
Print
End Sub
Private Sub Command5_Click()
Dim s%, i As Boolean
a = 0
s = Val(InputBox("请输入要删除的元素."))
While a < UBound(c)
a = a + 1
If c(a) = s Then
For b = a To UBound(c) - 1
c(b) = c(b + 1)
Next b
a = a - 1
i = True
ReDim Preserve c(UBound(c) - 1)
End If
Wend
If Not (i) Then MsgBox "none"
For a = 1 To UBound(c)
Print c(a);
If a Mod 10 = 0 Then Print
Next a
Print
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -