关于我的程序"溢出"的源代码code !!!!!!!!!!!!
Dim Text
Dim found
Dim Found_2
Dim url
Dim File_no
Dim Writed_no
Option Explicit
Private Sub Command1_Click()
If Option1.Value = True Then
CommonDialog1.ShowOpen
RichTextBox1.LoadFile CommonDialog1.FileName, rtfText
Do
sReplace RichTextBox1.Text, Text1.Text, Text2.Text
Loop Until Text1.ToolTipText = "0"
RichTextBox1.SaveFile CommonDialog1.FileName, rtfText
Text1.ToolTipText = ""
Else
Dim starttime As Single
findfilesdir Text3.Text, Text4.Text
End If
Do Until List1.ListCount = 0
RichTextBox1.Text = ""
RichTextBox1.LoadFile List1.List(0), rtfText
Do
sReplace RichTextBox1.Text, Text1.Text, Text2.Text
Loop Until Text1.ToolTipText = "0"
RichTextBox1.SaveFile List1.List(0), rtfText
List1.RemoveItem 0
Text1.ToolTipText = ""
Loop
End Sub
Private Sub Command2_Click()
RichTextBox1.SelStart = 0
Do Until found = -1
found = RichTextBox1.Find(Text1.Text, RichTextBox1.SelStart, , rtfWholeWord)
If found <> -1 Then
RichTextBox1.Span "", True, True
RichTextBox1.SelText = Text2.Text
Else
MsgBox "没有查到!"
End If
Loop
End Sub
Public Sub findfilesdir(DirPath As String, FileSpec As String)
Dim filestring As String
DirPath = Trim$(DirPath)
If Right$(DirPath, 1) <> "\" Then
DirPath = DirPath & "\"
End If
filestring = Dir$(DirPath & FileSpec, vbArchive Or vbHidden Or vbSystem Or vbDirectory)
Do
DoEvents
If filestring = "" Then
Exit Do
Else
If (GetAttr(DirPath & filestring) And vbDirectory) = vbDirectory Then
If Left$(filestring, 1) <> "." And Left$(filestring, 2) <> ".." Then
End If
Else
url = DirPath & filestring
List1.AddItem url
File_no = File_no + 1
End If
End If
filestring = Dir$
Loop
End Sub
Private Sub Form_Load()
Writed_no = 0
File_no = 0
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub Option1_Click()
Text3.Enabled = False
End Sub
Private Sub Option2_Click()
Text3.Enabled = True
End Sub
Function sReplace(SearchLine As String, SearchFor As String, ReplaceWith As String)
Dim vSearchLine As String, found As Integer
found = InStr(SearchLine, SearchFor): vSearchLine = SearchLine
If found <> 0 Then
vSearchLine = ""
If found > 1 Then vSearchLine = Left(SearchLine, found - 1)
vSearchLine = vSearchLine + ReplaceWith
If found + Len(SearchFor) - 1 < Len(SearchLine) Then _
vSearchLine = vSearchLine + Right$(SearchLine, Len(SearchLine) - found - Len(SearchFor) + 1)
End If
sReplace = vSearchLine
RichTextBox1.Text = sReplace
Text1.ToolTipText = found
End Function