这是道VB 题,

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 16:33:48
这是道VB 题,

这是道VB 题,
这是道VB 题,
 

这是道VB 题,
'1、说明-引用"Microsoft Rich Textbox 6.0" 控件,拖入窗体 ,Name=RichTextBox1;添加一个按钮 Name=cmdSearch
'2、注意-使用RichTextbox相对简单一点的做法,如果是普通文本框,复杂一点就要用到 API了
Option Explicit
Private lStart As Long

Private Sub cmdSearch_Click()
    Dim s As Long
    With RichTextBox1
        If lStart = 0 Then
            lStart = .Find("VB", 0, , rtfNoHighlight)
        Else
'            .SelColor = vbBlack
'            .SelFontSize = 9
'            .SelBold = False
            lStart = .Find("VB", lStart + 2, , rtfNoHighlight)
        End If
        If lStart < Len(.Text) - 1 Then
            .SelStart = lStart
            .SelLength = 2
        Else
            MsgBox "搜索完成"
        End If
'        .SelItalic = True
'        .SelBold = True
'        .SelColor = vbRed
'        .SelFontSize = 10
    End With
        
End Sub

Private Sub Form_Load()
    RichTextBox1.Text = "123VB456VB789VB"
    RichTextBox1.Font.Size = 9
    RichTextBox1.HideSelection = False
End Sub