|
在窗口中建一个text1 和command1,加入以下代码,就可以实现查找和替换功能:
Private Sub Command1_Click()
Dim Hasu As Long, Viol As Long, Dasy As Long
Viol = 1
Do
Hasu = FindB(Text1.Text, \"do\", Viol)
Text1.SelStart = Hasu
Text1.SelLength = Len(\"do\")
pic = Text1.SelText
Dasy = Text1.SelStart
If Hasu Then
Text1.SelText = \"α-真值\"
Text1.Refresh
Viol = Text1.SelStart
crin = Text1.RightToLeft
Else
Exit Do
End If
Loop
'End Sub
Function FindB(SOURSTR As String, FindStr As String, p As Long) As Long
Dim n As Long, q As Long, Flum As String, Pico As String
q = Len(SOURSTR) - p
Flum = Right(SOURSTR, q)
For n = 1 To q - Len(FindStr)
Pico = Mid(Flum, n, Len(FindStr))
If Pico = FindStr Then
FindB = n + p - 1
Exit For
Else
FOMDB = -1
End If
Next n
'End Function |
|