无非就是读取txt中的全部数据,每个网址之间有特殊符号隔开,循环打开每个网址 open pp.path &"/你的文本文件名.txt" for input #1 input #1, str
Option ExplicitDim vPrivate Sub Command1_Click() Dim s$, i% Open "c:\url.txt" For Input As #1 s = StrConv(InputB$(LOF(1), #1), vbUnicode) Close #1
Timer1.Enabled = True
v = Split(s, vbCrLf) End SubPrivate Sub Timer1_Timer() Static i As Integer
Err1: i = i + 1 If i > UBound(v) Then MsgBox "所有打开完毕!" If v(i) = "" Then GoTo Err1 WebBrowser1.Navigate v(i) End Sub
可以不使用Timer Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Dim i As Integer Private Sub Form_Load() i = 0 Dim MyString As String Open "c:\test.txt" For Input As #1 Do While Not EOF(1) DoEvents Line Input #1, MyString Loop Close #1 WebBrowser1.Navigate List1.List(i) End SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant) Me.Caption = URL i = i + 1 Sleep 1000 DoEvents If i >= List1.ListCount Then i = 0 WebBrowser1.Navigate List1.List(i) End Sub
错误提示是什么?在哪一行代码? 你可能是由于时间间隔导致的。Private Sub Command1_Click() Dim s$, i% Open "c:\url.txt" For Input As #1 s = StrConv(InputB$(LOF(1), #1), vbUnicode) Close #1
Open "c:\url.txt" For Input As #1 s = StrConv(InputB$(LOF(1), #1), vbUnicode) Close #1
v = Split(s, vbCrLf) For i = 0 To UBound(v) If v(i) = "" Then objTimer.Wait 70000 '延时70秒 WebBrowser1.Navigate v(i) End If Next End Sub不知道你是否一定需要打开网页后延时一段时间,如果只是要打开好就行的话用3L代码也行。
open pp.path &"/你的文本文件名.txt" for input #1
input #1, str
Dim s$, i%
Open "c:\url.txt" For Input As #1
s = StrConv(InputB$(LOF(1), #1), vbUnicode)
Close #1
Timer1.Enabled = True
v = Split(s, vbCrLf)
End SubPrivate Sub Timer1_Timer()
Static i As Integer
Err1:
i = i + 1
If i > UBound(v) Then MsgBox "所有打开完毕!"
If v(i) = "" Then GoTo Err1
WebBrowser1.Navigate v(i)
End Sub
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim i As Integer
Private Sub Form_Load()
i = 0
Dim MyString As String
Open "c:\test.txt" For Input As #1
Do While Not EOF(1)
DoEvents
Line Input #1, MyString
Loop
Close #1
WebBrowser1.Navigate List1.List(i)
End SubPrivate Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Me.Caption = URL
i = i + 1
Sleep 1000
DoEvents
If i >= List1.ListCount Then i = 0
WebBrowser1.Navigate List1.List(i)
End Sub
老公,非常感谢(我是男的哈),我如果想再form上加一个TXT,控制时间间隔应该怎么加入
我定义了一个J,J=val(text1.text)
timer1.interval=j
运行有错误,不知道为什么,请求您的帮助!
我定义了一个J,J=val(text1.text)
timer1.interval=j
运行有错误,不知道为什么,请求帮助!
你可能是由于时间间隔导致的。Private Sub Command1_Click()
Dim s$, i%
Open "c:\url.txt" For Input As #1
s = StrConv(InputB$(LOF(1), #1), vbUnicode)
Close #1
Timer1.Interval=10000'1000就表示1秒
Timer1.Enabled = True
v = Split(s, vbCrLf)
End Sub
Private Sub Command1_Click()
Dim s$, i%, j%
j = Val(Text1.Text) * 1000
Open "C:\Documents and Settings\Administrator\桌面\2.txt" For Input As #1
s = StrConv(InputB$(LOF(1), #1), vbUnicode)
Close #1
Timer1.Enabled = True
Timer1.Interval = j
v = Split(s, vbCrLf)
End Sub
实时错误13 ,类型不匹配If i > UBound(v) Then MsgBox "所有打开完毕!"
推荐一个延时类:
http://download.csdn.net/source/752060Private Sub Command1_Click()
Dim s$, i%, v
Dim objTimer As New clsWaitableTimer
Open "c:\url.txt" For Input As #1
s = StrConv(InputB$(LOF(1), #1), vbUnicode)
Close #1
v = Split(s, vbCrLf)
For i = 0 To UBound(v)
If v(i) = "" Then
objTimer.Wait 70000 '延时70秒
WebBrowser1.Navigate v(i)
End If
Next
End Sub不知道你是否一定需要打开网页后延时一段时间,如果只是要打开好就行的话用3L代码也行。