📄 顺序查找.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 2055
ClientLeft = 60
ClientTop = 465
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 2055
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "查找"
Height = 375
Left = 3360
TabIndex = 3
Top = 960
Width = 975
End
Begin VB.CommandButton Command1
Caption = "生成数组"
Height = 375
Left = 3360
TabIndex = 2
Top = 240
Width = 975
End
Begin VB.TextBox Text2
Height = 375
Left = 240
TabIndex = 1
Top = 960
Width = 2895
End
Begin VB.TextBox Text1
Height = 375
Left = 240
TabIndex = 0
Top = 240
Width = 2895
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Base 1
Dim search As Variant
Private Sub command1_click()
Dim element As Variant
search = Array(16, 39, 17, 12, 88, 76, 43, 27, 64, 50)
For Each element In search
Text1.Text = Text1.Text & Str(element)
Next element
End Sub
Private Sub Command2_Click()
Dim i As Integer, find As Integer
Text2.Text = ""
find = InputBox("输入要查找的数")
For i = 1 To UBound(search)
If search(i) = find Then Exit For
Next i
If i <= UBound(search) Then
Text2.Text = "要查找的数" & CStr(search(i)) & "是search(" & CStr(i) & ")"
Else
Text2.Text = "在数列中没有找到" & Str(find)
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -