📄 richtextboxselect.frm
字号:
VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 6015
ClientLeft = 60
ClientTop = 345
ClientWidth = 7530
LinkTopic = "Form1"
ScaleHeight = 6015
ScaleWidth = 7530
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command3
Caption = "退出"
Height = 315
Left = 6300
TabIndex = 3
Top = 4980
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "选择字符串"
Height = 315
Left = 6300
TabIndex = 2
Top = 4440
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "输入文本"
Height = 315
Left = 6300
TabIndex = 1
Top = 3840
Width = 1095
End
Begin RichTextLib.RichTextBox RichTextBox1
Height = 5955
Left = 0
TabIndex = 0
Top = 60
Width = 6075
_ExtentX = 10716
_ExtentY = 10504
_Version = 393217
Enabled = -1 'True
TextRTF = $"RichTextBoxSelect.frx":0000
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim str As String
Dim text As String
str = "输入文本"
text = InputBox(str)
RichTextBox1.text = text
End Sub
Private Sub Command2_Click()
Dim str As String
Dim text As String
Dim position As Integer
Dim length As Integer
str = "输入需选择的字符串"
text = InputBox(str)
If text <> "" Then
position = InStr(RichTextBox1.text, text) - 1
length = Len(text)
RichTextBox1.SelStart = position
RichTextBox1.SelLength = length
RichTextBox1.SelColor = RGB(255, 0, 0)
Do While InStr(position + length + 1, RichTextBox1.text, text) - 1 <> -1
position = InStr(position + length + 1, RichTextBox1.text, text) - 1
RichTextBox1.SelStart = position
RichTextBox1.SelLength = length
RichTextBox1.SelColor = RGB(255, 0, 0)
Loop
End If
End Sub
Private Sub Command3_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -