Private Sub CmdApply_Click()
Dim Text1 As String
Dim Text2 As String
Dim Text3 As String
Dim Text4 As String
Dim Text5 As String
Dim Text6 As String
Dim Text8 As String
Dim Text9 As String
Text1 = "<SIP CONFIG MODULE>"
Text2 = "SIP Port :" & TextLocalSIPPort.Text
Text3 = "Stun Address :" & TextSTUNServerAddr.Text
Text4 = "Stun Port :" & TextSTUNServerPort.Text
Text5 = "Stun Effect Time :" & TextSTUNEffectTime.Text
Text6 = "--SIP Line List-- :"
Text8 = "SIP1 Use Stun :" & CheckUseStun.Value
Text9 = "SIP2 Use Stun :" & CheckUseStun1.Value
'text2的替换模块
Dim FileNum As Long
Dim StrLine As String
Dim StrFileContent As String
Dim target As String
'获取用户输入的要查找的字符串
target = "SIP Port :"
FileNum = FreeFile
Open ".\Config.txt" For Input As #FileNum
Do Until EOF(FileNum)
Line Input #FileNum, StrLine
If InStr(StrLine, target) > 0 Then StrLine = Text2: target = "Slore"
StrFileContent = StrFileContent & StrLine & vbCrLf
Loop
Close #FileNum
Open ".\Config.txt" For Output As #FileNum
Print #FileNum, StrFileContent
Close #FileNum
If target <> "Slore" Then '没有找到了匹配字符串
Open ".\config.txt" For Append As #FileNum
Print #FileNum, Text1
Print #FileNum, Text2
End If
Close #FileNum
'text3的替换模块
Dim StrFileContent1 As String
Dim target1 As String
'获取用户输入的要查找的字符串
target1 = "Stun Address :"
Open ".\Config.txt" For Input As #FileNum
Do Until EOF(FileNum)
Line Input #FileNum, StrLine
If InStr(StrLine, target) > 0 Then StrLine = Text3: target1 = "Slore1"
StrFileContent = StrFileContent & StrLine & vbCrLf
Loop
Close #FileNum
Open ".\Config.txt" For Output As #FileNum
Print #FileNum, StrFileContent
Close #FileNum
If target1 <> "Slore1" Then '没有找到了匹配字符串
Open ".\config.txt" For Append As #FileNum
Print #FileNum, Text3
End If
Close #FileNum
Unload Stun
End Sub
我想拓展可就是不行,反而把前面的都搞错了!
帮我看看行不?真不想麻烦你,可是我实在是没办法,你谅解下哈
Private Sub CmdApply_Click()
Dim Text1 As String
Dim Text2 As String
Dim Text3 As String
Dim Text4 As String
Dim Text5 As String
Dim Text6 As String
Dim Text8 As String
Dim Text9 As String
Text1 = "<SIP CONFIG MODULE>"
Text2 = "SIP Port :" & TextLocalSIPPort.Text
Text3 = "Stun Address :" & TextSTUNServerAddr.Text
Text4 = "Stun Port :" & TextSTUNServerPort.Text
Text5 = "Stun Effect Time :" & TextSTUNEffectTime.Text
Text6 = "--SIP Line List-- :"
Text8 = "SIP1 Use Stun :" & CheckUseStun.Value
Text9 = "SIP2 Use Stun :" & CheckUseStun1.Value
'text2的替换模块
Dim FileNum As Long
Dim StrLine As String
Dim StrFileContent As String
Dim target As String
'获取用户输入的要查找的字符串
target = "SIP Port :"
FileNum = FreeFile
Open ".\Config.txt" For Input As #FileNum
Do Until EOF(FileNum)
Line Input #FileNum, StrLine
If InStr(StrLine, target) > 0 Then StrLine = Text2: target = "Slore"
StrFileContent = StrFileContent & StrLine & vbCrLf
Loop
Close #FileNum
Open ".\Config.txt" For Output As #FileNum
Print #FileNum, StrFileContent
Close #FileNum
If target <> "Slore" Then '没有找到了匹配字符串
Open ".\config.txt" For Append As #FileNum
Print #FileNum, Text1
Print #FileNum, Text2
End If
Close #FileNum
'text3的替换模块
Dim target1 As String
'获取用户输入的要查找的字符串
target1 = "Stun Address :"
Open ".\Config.txt" For Input As #FileNum
Do Until EOF(FileNum)
Line Input #FileNum, StrLine
If InStr(StrLine, target1) > 0 Then StrLine = Text3: target1 = "Slore1"
StrFileContent = StrFileContent & StrLine & vbCrLf
Loop
Close #FileNum
Open ".\Config.txt" For Output As #FileNum
Print #FileNum, StrFileContent
Close #FileNum
If target1 <> "Slore1" Then '没有找到了匹配字符串
Open ".\config.txt" For Append As #FileNum
Print #FileNum, Text3
End If
Close #FileNum
Unload Stun
End Sub
修改了下最明显的错误,但结果还是一样!