发布网友 发布时间:2022-02-26 11:23
共2个回答
热心网友 时间:2022-02-26 12:52
VB 中Find 语句用法,参考下列代码:
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即可复制
热心网友 时间:2022-02-26 14:10
重载有:
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即可复制