📄 form1.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents lblCh As System.Windows.Forms.Label
Friend WithEvents txtCh As System.Windows.Forms.TextBox
Friend WithEvents lblR As System.Windows.Forms.Label
Friend WithEvents btnSeek As System.Windows.Forms.Button
Friend WithEvents lblKeyIn As System.Windows.Forms.Label
Friend WithEvents txtKeyIn As System.Windows.Forms.TextBox
'Required by the Windows Form Designer
Private components As System.ComponentModel.Container
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.txtKeyIn = New System.Windows.Forms.TextBox
Me.btnSeek = New System.Windows.Forms.Button
Me.lblCh = New System.Windows.Forms.Label
Me.lblKeyIn = New System.Windows.Forms.Label
Me.lblR = New System.Windows.Forms.Label
Me.txtCh = New System.Windows.Forms.TextBox
Me.SuspendLayout()
'
'txtKeyIn
'
Me.txtKeyIn.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.txtKeyIn.Location = New System.Drawing.Point(19, 37)
Me.txtKeyIn.MaxLength = 20
Me.txtKeyIn.Name = "txtKeyIn"
Me.txtKeyIn.Size = New System.Drawing.Size(288, 26)
Me.txtKeyIn.TabIndex = 0
Me.txtKeyIn.Text = ""
'
'btnSeek
'
Me.btnSeek.Font = New System.Drawing.Font("Microsoft Sans Serif", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.btnSeek.Location = New System.Drawing.Point(125, 112)
Me.btnSeek.Name = "btnSeek"
Me.btnSeek.Size = New System.Drawing.Size(67, 22)
Me.btnSeek.TabIndex = 3
Me.btnSeek.Text = "搜索"
'
'lblCh
'
Me.lblCh.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.lblCh.Location = New System.Drawing.Point(19, 82)
Me.lblCh.Name = "lblCh"
Me.lblCh.Size = New System.Drawing.Size(211, 23)
Me.lblCh.TabIndex = 1
Me.lblCh.Text = "请输入要寻找的字符"
'
'lblKeyIn
'
Me.lblKeyIn.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.lblKeyIn.Location = New System.Drawing.Point(19, 7)
Me.lblKeyIn.Name = "lblKeyIn"
Me.lblKeyIn.Size = New System.Drawing.Size(173, 23)
Me.lblKeyIn.TabIndex = 1
Me.lblKeyIn.Text = "请输入一个字符串"
'
'lblR
'
Me.lblR.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.lblR.Location = New System.Drawing.Point(19, 149)
Me.lblR.Name = "lblR"
Me.lblR.Size = New System.Drawing.Size(288, 23)
Me.lblR.TabIndex = 0
'
'txtCh
'
Me.txtCh.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(136, Byte))
Me.txtCh.Location = New System.Drawing.Point(250, 75)
Me.txtCh.Name = "txtCh"
Me.txtCh.Size = New System.Drawing.Size(48, 26)
Me.txtCh.TabIndex = 2
Me.txtCh.Text = ""
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(326, 183)
Me.Controls.Add(Me.txtKeyIn)
Me.Controls.Add(Me.lblKeyIn)
Me.Controls.Add(Me.btnSeek)
Me.Controls.Add(Me.lblR)
Me.Controls.Add(Me.txtCh)
Me.Controls.Add(Me.lblCh)
Me.Name = "Form1"
Me.Text = "f10_3_2 顺序搜索法"
Me.ResumeLayout(False)
End Sub
#End Region
'************** f10_3_2 **************
Dim arr(19) As String
Dim i As Integer
Private Sub btnSeek_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSeek.Click
For i = 0 To 19
arr(i) = Mid(txtKeyIn.Text, i + 1, 1)
Next i
'顺序搜索法
For i = 0 To 19
If txtCh.Text = arr(i) Then
lblR.Text = txtCh.Text & "字符排列在第" & Str(i + 1) & " 顺序的位置"
Exit Sub
End If
Next i
lblR.Text = "查无数据"
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -