📄 5-7.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 6495
ClientLeft = 60
ClientTop = 405
ClientWidth = 4725
BeginProperty Font
Name = "宋体"
Size = 15.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
ScaleHeight = 6495
ScaleWidth = 4725
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "删除数据"
Height = 495
Left = 2280
TabIndex = 5
Top = 5520
Width = 1575
End
Begin VB.CommandButton Command1
Caption = "输入数据"
Height = 495
Left = 360
TabIndex = 4
Top = 5520
Width = 1575
End
Begin VB.ListBox List2
Height = 4155
ItemData = "5-7.frx":0000
Left = 2400
List = "5-7.frx":0002
TabIndex = 3
Top = 840
Width = 1335
End
Begin VB.ListBox List1
Height = 4155
ItemData = "5-7.frx":0004
Left = 360
List = "5-7.frx":0006
TabIndex = 2
Top = 840
Width = 1335
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "删除后:"
Height = 315
Left = 2400
TabIndex = 1
Top = 360
Width = 1260
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "原数组:"
Height = 315
Left = 360
TabIndex = 0
Top = 360
Width = 1260
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 As Integer
Private Sub Command1_Click()
List1.Clear: List2.Clear
Dim i As Integer
n = InputBox("输入数组大小n=?")
ReDim a(1 To n)
For i = 1 To n
a(i) = InputBox("请输入第" & i & "个数据。")
List1.AddItem a(i)
Next i
End Sub
Private Sub Command2_Click()
Dim x As Integer, i As Integer
x = InputBox("输入待删除的数据x=?")
For i = 1 To n
If a(i) = x Then
For j = i To n - 1
a(j) = a(j + 1)
Next j
Exit For
End If
Next i
ReDim Preserve a(1 To n - 1)
For i = 1 To n - 1
List2.AddItem a(i)
Next i
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -