September 21, 2018
Hot Topics:

Show the Find and Replace Dialogs

  • November 19, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

Add a new form. Add two command buttons, cmdFind and cmdReplace. Copy the following code into the form:

Option Explicit
'Find/Replace Type Structure
  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 Calls
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

'Delcaration of the type structure

Private Sub cmdFind_Click()
'Call the find text function
FindText frText
End Sub

Private Sub cmdReplace_Click()
'Call the replace text function
ReplaceText frText
End Sub

Private Sub Form_Load()
'Set the Find/Replace Type properties
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

Page 2 of 2

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.


Thanks for your registration, follow us on our social networks to keep up-to-date