vb中的FIND语句怎么使用?

vb2008的richtextbox.find过程怎么使用?如果想高亮或复制找到的语句又该怎么写?... vb2008的richtextbox.find过程怎么使用?
如果想高亮或复制找到的语句又该怎么写?
展开
 我来答
dong_1984dd
推荐于2016-09-13 · TA获得超过1.1万个赞
知道小有建树答主
回答量:1070
采纳率:100%
帮助的人:231万
展开全部
  1. VB 中Find 语句用法,参考下列代码:

  2. Private Sub CommandButton11_Click() '查询
    Set gh = CreateObject("scripting.dictionary")
    Set xm = CreateObject("scripting.dictionary")
    Set zw = CreateObject("scripting.dictionary")
    'Application.WorksheetFunction.CountA([D:D]) Paste
    'Dim gh As Integer, xm As Integer, zw As Integer
    If TextBox6.Text = "" Then
       MsgBox "请输入查询内容!", , "友情提示"
    Else
      Set gh = Sheets("人员名单").Range("B1:B65536").Cells.Find(TextBox6.Text).Row
      Set xm = Sheets("人员名单").Range("C1:C65536").Cells.Find(TextBox6.Text).Row
      Set zw = Sheets("人员名单").Range("E1:E65536").Cells.Find(TextBox6.Text).Row
       If Not gh Is Nothing Or Not xm Is Nothing Or Not zw Is Nothing Then
           MsgBox "请输入查询内容!", , "友情提示"
       End If
        If OptionButton3.Value = True Then '按工号查找
           TextBox1.Text = gh - 2
        With Sheets("人员名单")
             TextBox2.Text = .Cells(TextBox1.Text + 2, 2)
             TextBox3.Text = .Cells(TextBox1.Text + 2, 3)
             ComboBox1.Text = .Cells(TextBox1.Text + 2, 4)
             ComboBox2.Text = .Cells(TextBox1.Text + 2, 5)
             TextBox4.Text = .Cells(TextBox1.Text + 2, 6)
             ComboBox3.Text = .Cells(TextBox1.Text + 2, 7)
             ComboBox4.Text = .Cells(TextBox1.Text + 2, 8)
             If .Cells(TextBox1.Text + 2, 9) <> "" Then
                 DTPicker1.Value = .Cells(TextBox1.Text + 2, 9)
             Else
                 DTPicker1.Value = Now
             End If
            If .Cells(TextBox1.Text + 2, 10) = "是" Then
                OptionButton1.Value = True
            Else
                OptionButton2.Value = True
            End If
            TextBox5.Text = .Cells(TextBox1.Text + 2, 21)
            If .Cells(TextBox1.Text + 2, 20) <> "" Then
                DTPicker2.Value = .Cells(TextBox1.Text + 2, 20)
            Else
                DTPicker2.Value = Now
            End If
            For i = 1 To 9
                   Me.Controls("CheckBox" & i).Value = False
               If .Cells(TextBox1.Text + 2, i + 10) = "√" Then
                   Me.Controls("CheckBox" & i).Value = True
               End If
            Next i
        End With
        Else
        If OptionButton4.Value = True Then '按姓名查找
           TextBox1.Text = xm - 2
        With Sheets("人员名单")
             TextBox2.Text = .Cells(TextBox1.Text + 2, 2)
             TextBox3.Text = .Cells(TextBox1.Text + 2, 3)
             ComboBox1.Text = .Cells(TextBox1.Text + 2, 4)
             ComboBox2.Text = .Cells(TextBox1.Text + 2, 5)
             TextBox4.Text = .Cells(TextBox1.Text + 2, 6)
             ComboBox3.Text = .Cells(TextBox1.Text + 2, 7)
             ComboBox4.Text = .Cells(TextBox1.Text + 2, 8)
             If .Cells(TextBox1.Text + 2, 9) <> "" Then
                 DTPicker1.Value = .Cells(TextBox1.Text + 2, 9)
             Else
                 DTPicker1.Value = Now
             End If
            If .Cells(TextBox1.Text + 2, 10) = "是" Then
                OptionButton1.Value = True
            Else
                OptionButton2.Value = True
            End If
            TextBox5.Text = .Cells(TextBox1.Text + 2, 21)
            If .Cells(TextBox1.Text + 2, 20) <> "" Then
                DTPicker2.Value = .Cells(TextBox1.Text + 2, 20)
            Else
                DTPicker2.Value = Now
            End If
            For i = 1 To 9
                   Me.Controls("CheckBox" & i).Value = False
               If .Cells(TextBox1.Text + 2, i + 10) = "√" Then
                   Me.Controls("CheckBox" & i).Value = True
               End If
            Next i
        End With
        Else
        If OptionButton5.Value = True Then '按职位查找
           TextBox1.Text = zw - 2
        With Sheets("人员名单")
             TextBox2.Text = .Cells(TextBox1.Text + 2, 2)
             TextBox3.Text = .Cells(TextBox1.Text + 2, 3)
             ComboBox1.Text = .Cells(TextBox1.Text + 2, 4)
             ComboBox2.Text = .Cells(TextBox1.Text + 2, 5)
             TextBox4.Text = .Cells(TextBox1.Text + 2, 6)
             ComboBox3.Text = .Cells(TextBox1.Text + 2, 7)
             ComboBox4.Text = .Cells(TextBox1.Text + 2, 8)
             If .Cells(TextBox1.Text + 2, 9) <> "" Then
                 DTPicker1.Value = .Cells(TextBox1.Text + 2, 9)
             Else
                 DTPicker1.Value = Now
             End If
            If .Cells(TextBox1.Text + 2, 10) = "是" Then
                OptionButton1.Value = True
            Else
                OptionButton2.Value = True
            End If
            TextBox5.Text = .Cells(TextBox1.Text + 2, 21)
            If .Cells(TextBox1.Text + 2, 20) <> "" Then
                DTPicker2.Value = .Cells(TextBox1.Text + 2, 20)
            Else
                DTPicker2.Value = Now
            End If
            For i = 1 To 9
                   Me.Controls("CheckBox" & i).Value = False
               If .Cells(TextBox1.Text + 2, i + 10) = "√" Then
                   Me.Controls("CheckBox" & i).Value = True
               End If
            Next i
        End With
        Else
            MsgBox "请按相应选项进行查找!", , "友情提示"
          End If
        End If
      End If
    End If
    End Sub

3.重载有:

public int Find(char[ ] characterSet)

public int Find(char[ ] characterSet, int start)

public int Find(char[ ] characterSet, int start, int end)

public int Find(string str)

public int Find(string str, System.Windows.Forms.RichTextBoxFinds options)

public int Find(string str, int start, System.Windows.Forms.RichTextBoxFinds options)

public int Find(string str, int start, int end, System.Windows.Forms.RichTextBoxFinds options)

 

characterSet和str:指要在控件中定位的文本

start:控件文本中开始搜索的位置

end:控件文本中结束搜索的位置。此值必须等于 -1 或者大于或等于 start 参数

options:System.Windows.Forms.RichTextBoxFinds 值的按位组合

 

4.一般来讲用Find(str, start, end)就行了,使用后,如果options不为NoHighlight,就会自动在文本框中选中,然后使用richtextbox.copy即可复制

百度网友d1855349d
推荐于2017-12-16 · TA获得超过430个赞
知道小有建树答主
回答量:425
采纳率:0%
帮助的人:0
展开全部
重载有:
public int Find(char[ ] characterSet)
public int Find(char[ ] characterSet, int start)
public int Find(char[ ] characterSet, int start, int end)
public int Find(string str)
public int Find(string str, System.Windows.Forms.RichTextBoxFinds options)
public int Find(string str, int start, System.Windows.Forms.RichTextBoxFinds options)
public int Find(string str, int start, int end, System.Windows.Forms.RichTextBoxFinds options)

characterSet和str:指要在控件中定位的文本
start:控件文本中开始搜索的位置
end:控件文本中结束搜索的位置。此值必须等于 -1 或者大于或等于 start 参数
options:System.Windows.Forms.RichTextBoxFinds 值的按位组合

一般来讲用Find(str, start, end)就行了,你使用后,如果options不为NoHighlight,就会自动在文本框中选中,然后使用richtextbox.copy即可复制
本回答被提问者和网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式