<SIP CONFIG MODULE>
SIP Port :5060
我在TextLocalSIPPort里重新输入了一个数值比如是300
那么点击apply键就会更新掉
文本里就看不到
SIP Port :5060
会看到
SIP Port :300
那这样说吧
文本里有以下数据:
<SIP CONFIG MODULE>
SIP Port :5060
Stun Address :
Stun Port :3478
Stun Effect Time :50
Stun Address :
当我再次点击apply的时候把TextLocalSIPPort里重新输入了一个数值比如是300
那么我希望在文本里看到的是
<SIP CONFIG MODULE>
SIP Port :300
Stun Address :
Stun Port :3478
Stun Effect Time :50
Stun Address :
就只有我在文本框里改变了的就在文本文件里更新,其他没做改动的都不变
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
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 #1
Print #1, Text1
Print #1, Text2
End If
Close #1
Unload Stun
End Sub
你的POS的instr使用错误!
要查找位置必须先读取文本!你的那个ReplaceInFile函数在你的代码里就没有用……