VB 刷网站代码
VB 刷网站代码
2011年03月18日
以下代码送给开网站的朋友们
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ ↓↓↓ ↓↓↓↓第 一 种↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓代 码↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
Dim i As Long ' 计数变量
Dim w As Long '窗体宽度变量
Dim h As Long '窗体高度变量
'文件的读写
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim fso As Object
Dim fso_file As Object
'
Private Sub Cmd_OK_Click()
Dim j As Integer
Dim temp As Boolean
temp = False '不存在此条记录
'如果不为空,则判断该记录是否已经存在
If Combo1.ListCount 0 Then
For j = 0 To Combo1.ListCount - 1
'如果该记录存在,没有必要再循环下去,直接退出for循环
If Combo1.Text = Combo1.List(j) Then
temp = True ' 存在此条记录
Exit For
End If
Next j
If temp = False Then
Combo1.AddItem Combo1.Text '如果不存在,则添加
Set fso_file = fso.OpenTextFile(App.Path + "\url.txt", ForAppending, True)
fso_file.WriteLine Combo1.Text
fso_file.Close
End If
ElseIf Combo1.ListCount = 0 Then
Combo1.AddItem Combo1.Text '如果记录为零则直接添加
End If
'刷新时间间隔
Timer1.Interval = Val(Text1.Text) * 1000
'刷新网页所指向的网址
WebBrowser1.Navigate Combo1.Text
'刷新计时开始
Timer1.Enabled = True
'确定 按钮失效
Cmd_OK.Enabled = False
'激活 取消按钮
Cmd_Cancel.Enabled = True
End Sub
Private Sub Cmd_Cancel_Click()
'停止刷新
Timer1.Enabled = False
'刷新次数归零
i = 0
Label3.Caption = ""
'取消 按钮失效
Cmd_Cancel.Enabled = False
'激活 确定按钮
Cmd_OK.Enabled = True
End Sub
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ ↓↓↓↓↓↓↓第 二 种 代 码↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
。Private Sub Form_Load()
'读取历史记录到下拉列表
Set fso = CreateObject("Scripting.FileSystemObject")
Set fso_file = fso.OpenTextFile(App.Path + "\url.txt", ForReading, True)
Do While Not fso_file.AtEndOfStream
Combo1.AddItem fso_file.ReadLine
Loop
fso_file.Close
'初始页为上次刷新的网页
WebBrowser1.Navigate Combo1.Text
'程序初始化,不对网页进行刷新
Timer1.Enabled = False
'取消 按钮失效
Cmd_Cancel.Enabled = False
'记录窗体的大小
w = Me.Width
h = Me.Height
End Sub
Private Sub Form_Resize()
On Error GoTo ToExit '避开最小化窗体的时候不能调整窗体大小的错误
'------------------------------------------------
'保持窗体大小不变
Me.Height = h
Me.Width = w
'------------------------------------------------
Exit Sub
'----------------
ToExit:
Resume Next
End Sub
Private Sub Text1_Change()
'输入错误,清空重新输入
If IsNumeric(Text1.Text) = False Or Val(Text1.Text) >= 65 Then
Text1.Text = ""
Label3.Caption = "输入有误,请重新输入。"
Cmd_OK.Enabled = False
Else
Label3.Caption = ""
Cmd_OK.Enabled = True
End If
Exit Sub
End Sub
Private Sub Timer1_Timer()
'刷新网页所指向的网址
WebBrowser1.Navigate Combo1.Text
'记录刷新次数
i = i + 1
'显示刷新次数
Label3.Caption = "刷新次数:" & CStr(i)
End Sub
以上代码由 Alan、 Joey、LULU、Princess破解修改。。。。。。。。。以上代码仅供学习如用于商业,其法律责任不与我们4人发生任何责任
猜你喜欢
转载自liq39liq.iteye.com/blog/1358996
今日推荐
周排行