"查找全部"和"全部替换"的功能如何实现?

couragetodream 2005-09-04 03:59:32
想的我头疼,干脆直接问吧.

CommonDialog中有通用的查找与替换的对话框吗?
怎样使所查找的关键字在textbox或richtextbox中全部显示(选中状态)?
如果"查找"与"替换"两个按钮使用同一个文本框作为输入关键字的载体的话该怎么办?
...全文
250 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
couragetodream 2005-09-10
  • 打赏
  • 举报
回复
已收到,谢谢!
couragetodream 2005-09-10
  • 打赏
  • 举报
回复
以收到,谢谢!
threenewbee 2005-09-09
  • 打赏
  • 举报
回复
Find/Replace 是非模态对话框,和主程序用消息通信,实现起来比较复杂,我有一个稳定的 Find/Replace 代码。
要的留EMail
threenewbee 2005-09-09
  • 打赏
  • 举报
回复
寄出,收到请回信
couragetodream 2005-09-09
  • 打赏
  • 举报
回复
好像不太稳定啊
couragetodream 2005-09-09
  • 打赏
  • 举报
回复
letters@sina.com

谢谢
VBDN 2005-09-06
  • 打赏
  • 举报
回复
'声明 Type FINDREPLACE
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
'在表单中加入二个 Command Button,并命名为 cmdFind, cmdReplace,加入以下程序代码:
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
couragetodream 2005-09-06
  • 打赏
  • 举报
回复
谢谢
SetMeFree 2005-09-06
  • 打赏
  • 举报
回复
还是用VC吧,呵呵……有现成的类
couragetodream 2005-09-05
  • 打赏
  • 举报
回复
解决这些问题很复杂吗?
couragetodream 2005-09-05
  • 打赏
  • 举报
回复
couragetodream 2005-09-05
  • 打赏
  • 举报
回复
替换之前要查找一次,然后替换,然后再查找,然后再替换,直到找不到为止...该怎么办啊?
igxk 2005-09-04
  • 打赏
  • 举报
回复
1.用API函数可以实现这个对话框,但函数名我忘了。
2.用 INSTR 和 REPLACE 函数可以实现查找与替换。
couragetodream 2005-09-04
  • 打赏
  • 举报
回复
不明白
VBDN 2005-09-04
  • 打赏
  • 举报
回复
关于查找与替换的内容,请参见:
http://blog.csdn.net/VBDN/archive/2005/03/16/321378.aspx

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧