17466.html
来自「VB技巧问答10000例,是一个教程」· HTML 代码 · 共 23 行
HTML
23 行
<html> <head> <title>Re: 关于"寻找"功能</title> </head> <body bgcolor="#FFFFFF" vlink="#808080"> <center> <h1>Re: 关于"寻找"功能</h1> </center><hr size=7 width=75%><hr size=7 width=75%><p>Posted by <a href="mailto:luo570@ms31.hinet.net">小琳</a> on August 18, 1999 at 21:50:48:<p>In Reply to: <a href="17459.html">关于"寻找"功能</a> posted by Steven Sin on August 18, 1999 at 19:45:46:<p>: 怎样写才可以在 RichTextBox 里有寻找字串的功能?<p>:::在Form里面放入Richtextbox,Textbox及一个按钮,执行这个<br>程式时,在TextBox里面键入搜寻的字串,然后按下Enter键<br>,按钮的目的是假如有二个以上符合的话,可以使用向下<br>来搜寻,程式如下:<br>Option Explicit<br>Dim temp As Integer<p>Private Sub Command1_Click()<br> temp = temp + 1<br> temp = InStr(temp, RichTextBox1.Text, Trim(Text1.Text))<br> If temp = 0 Then<br> MsgBox "没有找到"<br> Else<br> MsgBox "有找到"<br> RichTextBox1.SetFocus<br> RichTextBox1.SelStart = temp - 1<br> RichTextBox1.SelLength = 1<br> End If<br> <br>End Sub<p>Private Sub Form_Load()<br> temp = 1<br> Command1.Enabled = False<br>End Sub<p>Private Sub Text1_KeyPress(KeyAscii As Integer)<br> <br> If KeyAscii = 13 Then<br> temp = InStr(temp, RichTextBox1.Text, Trim(Text1.Text))<br> If temp = 0 Then<br> MsgBox "没有找到"<br> Else<br> MsgBox "有找到"<br> Command1.Enabled = True<br> RichTextBox1.SetFocus<br> RichTextBox1.SelStart = temp - 1<br> RichTextBox1.SelLength = 1<br> End If<br> End If<br> <br>End Sub<br><br><br><hr size=7 width=75%><p><a name="followups">Follow Ups:</a><br><ul><!--insert: 17466--></ul><!--end: 17466--><br><hr size=7 width=75%><p></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?