If munx = False Then If MatchCase = True Then findnt = InStr(findnt + 1, Form1.Text1.Text, Text1.Text) Else findnt = InStr(findnt + 1, Form1.Text1.Text, Text1.Text, 1) End If If findnt <> 0 Then Form1.Text1.SelStart = findnt - 1 Form1.Text1.SelLength = Len(Text1.Text) Else MsgBox "没有找到" & Chr$(34) & Text1.Text & Chr$(34) End If End If If findnt <> 0 Then Form1.Text1.SelText = Text2.Text End If End Sub 这是我编的一替换功能....
因為這關系到文件操作,我使用以下辦法,在form中畫一個text和command.再首先設置text1屬性 text1.scrollbars=2 text1.multiline=true 之後寫入以下代碼 Option Explicit Private Sub Command1_Click() Dim fil As Integer Dim inputdata fil = FreeFile() Text1.Text = Replace(Text1.Text, "abc", "efg") Open App.Path + "\text.txt" For Output As #fil Print #fil, Text1 Close #fil End SubPrivate Sub Form_Load() Text1.Text = "" Dim fil As Integer Dim inputdata fil = FreeFile() Open App.Path + "\text.txt" For Input As #filDo While Not EOF(fil) Line Input #fil, inputdata Text1.Text = Text1.Text + inputdata Loop Close #filEnd Sub 快放分吧!
If munx = False Then
If MatchCase = True Then
findnt = InStr(findnt + 1, Form1.Text1.Text, Text1.Text)
Else
findnt = InStr(findnt + 1, Form1.Text1.Text, Text1.Text, 1)
End If
If findnt <> 0 Then
Form1.Text1.SelStart = findnt - 1
Form1.Text1.SelLength = Len(Text1.Text)
Else
MsgBox "没有找到" & Chr$(34) & Text1.Text & Chr$(34)
End If
End If If findnt <> 0 Then
Form1.Text1.SelText = Text2.Text
End If
End Sub
这是我编的一替换功能....
text1.scrollbars=2
text1.multiline=true
之後寫入以下代碼
Option Explicit
Private Sub Command1_Click()
Dim fil As Integer
Dim inputdata
fil = FreeFile()
Text1.Text = Replace(Text1.Text, "abc", "efg")
Open App.Path + "\text.txt" For Output As #fil
Print #fil, Text1
Close #fil
End SubPrivate Sub Form_Load()
Text1.Text = ""
Dim fil As Integer
Dim inputdata
fil = FreeFile()
Open App.Path + "\text.txt" For Input As #filDo While Not EOF(fil)
Line Input #fil, inputdata
Text1.Text = Text1.Text + inputdata
Loop
Close #filEnd Sub
快放分吧!