⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmfind.frm

📁 记事本
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmFind 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "查找"
   ClientHeight    =   1425
   ClientLeft      =   5340
   ClientTop       =   6030
   ClientWidth     =   6120
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   ScaleHeight     =   1425
   ScaleWidth      =   6120
   Begin VB.CheckBox chkLU 
      Caption         =   "区分大小写"
      Height          =   375
      Left            =   120
      TabIndex        =   7
      Top             =   720
      Width           =   1455
   End
   Begin VB.Frame fraUD 
      Caption         =   "方向"
      Height          =   735
      Left            =   1920
      TabIndex        =   4
      Top             =   600
      Width           =   2055
      Begin VB.OptionButton optDown 
         Caption         =   "向下"
         Height          =   255
         Left            =   1080
         TabIndex        =   6
         Top             =   240
         Width           =   855
      End
      Begin VB.OptionButton optUp 
         Caption         =   "向上"
         Height          =   255
         Left            =   120
         TabIndex        =   5
         Top             =   240
         Width           =   735
      End
   End
   Begin VB.TextBox txtFind 
      Height          =   375
      Left            =   1200
      TabIndex        =   2
      Top             =   120
      Width           =   2775
   End
   Begin VB.CommandButton cmdCancle 
      Caption         =   "取消"
      Height          =   375
      Left            =   4200
      TabIndex        =   1
      Top             =   600
      Width           =   1695
   End
   Begin VB.CommandButton cmdFind 
      Caption         =   "查找下一个"
      Height          =   375
      Left            =   4200
      TabIndex        =   0
      Top             =   120
      Width           =   1695
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      Caption         =   "查找内容:"
      Height          =   255
      Left            =   0
      TabIndex        =   3
      Top             =   120
      Width           =   1095
   End
End
Attribute VB_Name = "frmFind"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim StartPos As Integer

Private Sub cmdCancle_Click()
 Unload frmFind
End Sub

Private Sub cmdFind_Click()
Static FoundPos As Integer
Static Flag As Integer
sting = frmNote.rtfText.Text
If Fstring = "" Then
 Fstring = txtfind.Text
Else
 If txtfind.Text <> Fstring And txtfind.Text <> "" Then
  Fstring = txtfind.Text
 End If
End If
If StartPos = 0 Then
 StartPos = 1
End If
If optDown = True Then
 If chkLU.Value = 1 Then
  FoundPos = InStr(StartPos, sting, Fstring, 0)
 Else
  FoundPos = InStr(StartPos, sting, Fstring, 1)
 End If
       If FoundPos > 0 Then '找到了匹配字符串
            Flag = FoundPos ''''''记录位置
            MyPos = FoundPos - 1
            frmNote.rtfText.SelStart = MyPos '高亮显示
            frmNote.rtfText.SelLength = Len(txtfind.Text)
            StartPos = FoundPos + Len(Fstring)
        Else
            MsgBox "“" + txtfind.Text + " ”" + "没找到!", vbInformation, "记事本"
        End If
Else
Dim start As Integer
Dim pos As Integer
start = 1
  Do While pos < Flag ' 向前查找
    StartPos = start
    n = pos '记录最后一次找到位置
    If chkLU.Value = 1 Then
     pos = InStr(StartPos, sting, Fstring, 0)
    Else
     pos = InStr(StartPos, sting, Fstring, 1)
    End If
    If pos <> 0 Then
     start = pos + Len(Fstring)
    Else
     Exit Do
    End If
  Loop
    FoundPos = n
    If FoundPos <> 0 Then
     frmNote.rtfText.SelStart = FoundPos - 1  '高亮显示
     frmNote.rtfText.SelLength = Len(txtfind.Text)
     Flag = FoundPos
    Else
     MsgBox "“" + txtfind.Text + " ”" + "没找到!", vbInformation, "记事本"
    End If
End If
End Sub

Private Sub Form_Load()
 frmFind.Show
 optDown.Value = True
 txtfind.SetFocus
 StartPos = 1
 cmdFind.Enabled = False
End Sub

Private Sub optUp_Click()
optUp.Value = True
End Sub

Private Sub txtfind_Change()
If Len(txtfind) = 0 Then
 cmdFind.Enabled = False
Else
 cmdFind.Enabled = True
 End If
End Sub

'SelStart

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -