高手帮下忙,想换行后再写入。谢谢。Private Sub Command1_Click()
Dim d() As String, t As String
Dim l As Long
Open "c:\WINDOWS\system32\drivers\etc\hosts" For Input As #1
While Not EOF(1)
Line Input #1, t
t = Trim(t)
If Left(t, 1) <> "#" And Len(t) > 0 Then
ReDim Preserve d(0 To l) As String
d(l) = UCase(t)
l = l + 1
End If
Wend
Close #1
For l = 0 To UBound(d)
If InStr(d(l), UCase(Text2.Text)) > 0 Then '这里只检查网址,也可以改成text1.text就是检查IP的
MsgBox "定义有重复" & d(l)
Exit Sub
End If
Next l
Open "c:\WINDOWS\system32\drivers\etc\hosts" For Append As #1
Print #1, Text1.Text & " " & Text2.Text
Close #1
End Sub
Private Sub Form_Load()
Text1.Text = "127.0.0.1"
Text2.Text = "www.baidu.com"
End Sub
------------------
写入的这个文本里 有内容了,但现在是直接在内容后面接着写入想先换行,再写入请帮忙看下。。谢谢。
Dim d() As String, t As String
Dim l As Long
Open "c:\WINDOWS\system32\drivers\etc\hosts" For Input As #1
While Not EOF(1)
Line Input #1, t
t = Trim(t)
If Left(t, 1) <> "#" And Len(t) > 0 Then
ReDim Preserve d(0 To l) As String
d(l) = UCase(t)
l = l + 1
End If
Wend
Close #1
For l = 0 To UBound(d)
If InStr(d(l), UCase(Text2.Text)) > 0 Then '这里只检查网址,也可以改成text1.text就是检查IP的
MsgBox "定义有重复" & d(l)
Exit Sub
End If
Next l
Open "c:\WINDOWS\system32\drivers\etc\hosts" For Append As #1
Print #1, Text1.Text & " " & Text2.Text
Close #1
End Sub
Private Sub Form_Load()
Text1.Text = "127.0.0.1"
Text2.Text = "www.baidu.com"
End Sub
------------------
写入的这个文本里 有内容了,但现在是直接在内容后面接着写入想先换行,再写入请帮忙看下。。谢谢。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货