调用系统的查找替换对话框,如果坚持自己写的话可以用InstrRev试试 Private Type FINDREPLACE lStructSize As Long hwndOwner As Long hInstance As Long flags As Long lpstrFindWhat As String lpstrReplaceWith As String wFindWhatLen As Integer wReplaceWithLen As Integer lCustData As Long lpfnHook As Long lpTemplateName As String End Type'调用 Common Dialog DLL Private Declare Function FindText Lib "comdlg32.dll" Alias "FindTextA" _ (pFindreplace As FINDREPLACE) As Long Private Declare Function ReplaceText Lib "comdlg32.dll" Alias "ReplaceTextA" _ (pFindreplace As FINDREPLACE) As Long Dim frText As FINDREPLACE Private Sub cmdFind_Click() FindText frText '调用查找对话框 End Sub Private Sub cmdReplace_Click() ReplaceText frText '调用替换对话框 End Sub Private Sub form_Load() With frText .lpstrReplaceWith = "Replace Text" .lpstrFindWhat = "Find Text" .wFindWhatLen = 9 .wReplaceWithLen = 12 .hInstance = App.hInstance .hwndOwner = Me.hWnd .lStructSize = LenB(frText) End With End Sub
To goodname008(卢培培,想学好VB) 谢谢您的提醒,我怎么把VB自身提供的函数忘了呢 To rainstormmaster(rainstormmaster) 您的的办法果然管用。出现了系统查找替换对话框,但是如何让他跟Form1.Text1关联起来? 就像NotePad.Exe 还有,这三个是干什么用的? lCustData As Long lpfnHook As Long lpTemplateName As String
描述返回一个字符串在另一个字符串中出现的位置,从字符串的末尾算起。语法InstrRev(string1, string2[, start[, compare]])InstrRev函数语法有如下几部分:部分 描述
string1 必需的。要执行搜索的字符串表达式。
string2 必需的。要搜索的字符串表达式。
start 可选的。数值表达式,设置每次搜索的开始位置。如果忽略,则使用–1,它表示从上一个字符位置开始搜索。如果start包含
Null,则产生一个错误。
compare 可选的。数字值,指出在判断子字符串时所使用的比较方法。如果忽略,则执行二进制比较。关于其值,请参阅“设置值”部分。
设置值compare参数值如下:常数 值 描述
vbUseCompareOption –1 用Option Compare语句的设置值来执行比较。
vbBinaryCompare 0 执行二进制比较。
vbTextCompare 1 执行文字比较。
vbDatabaseCompare 2 只用于Microsoft Access。基于您的数据库信息执行比较。
返回值InStrRev返回值如下:如果 InStrRev返回
string1长度为零。 0
string1为Null。 Null
string2长度为零 Start
string2为Null Null
string2没有找到。 0
string2在string1中找到。 找到匹配字符串的位置。
start > Len(string2) 0
说明请注意,InstrRev函数的语法和Instr函数的语法不相同。
Private Type FINDREPLACE
lStructSize As Long
hwndOwner As Long
hInstance As Long
flags As Long
lpstrFindWhat As String
lpstrReplaceWith As String
wFindWhatLen As Integer
wReplaceWithLen As Integer
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type'调用 Common Dialog DLL
Private Declare Function FindText Lib "comdlg32.dll" Alias "FindTextA" _
(pFindreplace As FINDREPLACE) As Long
Private Declare Function ReplaceText Lib "comdlg32.dll" Alias "ReplaceTextA" _
(pFindreplace As FINDREPLACE) As Long
Dim frText As FINDREPLACE Private Sub cmdFind_Click()
FindText frText '调用查找对话框
End Sub
Private Sub cmdReplace_Click()
ReplaceText frText '调用替换对话框
End Sub
Private Sub form_Load()
With frText
.lpstrReplaceWith = "Replace Text"
.lpstrFindWhat = "Find Text"
.wFindWhatLen = 9
.wReplaceWithLen = 12
.hInstance = App.hInstance
.hwndOwner = Me.hWnd
.lStructSize = LenB(frText)
End With
End Sub
谢谢您的提醒,我怎么把VB自身提供的函数忘了呢
To rainstormmaster(rainstormmaster)
您的的办法果然管用。出现了系统查找替换对话框,但是如何让他跟Form1.Text1关联起来?
就像NotePad.Exe
还有,这三个是干什么用的?
lCustData As Long
lpfnHook As Long
lpTemplateName As String