Private Declare Function InternetHangUp Lib "wininet.dll" _
(ByVal dwConnection As Long, _
ByVal dwReserved As Long) As Long
Private Declare Function InternetAutodial Lib "wininet.dll" _
(ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Private Declare Function InternetAutodialHangup Lib "wininet.dll" _
(ByVal dwReserved As Long) As Long
Private Sub Check1_Click()
判断用户的选择
If Check1.Value = 0 Then
Text2.Enabled = False
Check2.Value = 0
Else
Text2.Enabled = True
End If
End Sub
Private Sub Check2_Click()
判断用户的选择
If Check2.Value = 0 Then
Text3.Enabled = False
Else
Text3.Enabled = True
End If
End Sub
Private Sub Command1_Click()
使设置生效并显示设置信息
Dim alert1, alert2
If Check1.Value = 1 And Check2.Value = 1 Then
If Not IsDate(Text2.Text) Or Not IsDate(Text3.Text) Then
MsgBox ("你输入的不是时间格式,请重试!")
Else
alert1 = Text2.Text
alert2 = Text3.Text
Label2.Caption = "注意:计算机将在" + Text2.Text + "登陆网络"
Label3.Caption = "注意:计算机将在" + Text3.Text + "断开网络"
Timer1.Enabled = True
End If
Else
If Check1.Value = 1 Then
If Not IsDate(Text2.Text) Then
MsgBox ("你输入的不是时间格式,请重试!")
Else
alert1 = Text2.Text
Label2.Caption = "注意:计算机将在" + Text2.Text + "登陆网络"
Timer1.Enabled = True
End If
End If
End If
End Sub
Private Sub Command2_Click()
取消设置并显示取消信息
If Check1.Value = 1 And Check2.Value = 1 Then
Text2.Text = "00:00:00"
Text3.Text = "00:00:00"
Timer1.Enabled = False
Label2.Caption = "注意:你已取消了定时登陆网络"
Label3.Caption = "注意:你已取消了定时断开网络"
Else
If Check1.Value = 1 Then
Text2.Text = "00:00:00"
Timer1.Enabled = False
Label2.Caption = "注意:你已取消了定时登陆网络"
End If
End If
End Sub
Private Sub Command3_Click()
这里默认以163拨号方式实现登陆,其它拨号方式只需修改一下参数就可以了。
InternetDial Me.hWnd, "163", INTERNET_AUTODIAL_FORCE_UNATTENDED, iHandle, 0
End Sub
Private Sub Form_Load()
初始化上网和下网的时间格式
Text2.Text = "00:00:00"
Text3.Text = "00:00:00"
End Sub
Private Sub Timer1_Timer()
根据用户的选择来判断实现定时上下网
Dim A
If Check1.Value = 1 And Check2.Value = 1 Then
Text1.Text = Time
A = TimeValue(Text1.Text)
If Text2.Text = A Then
InternetDial Me.hWnd, "163", INTERNET_AUTODIAL_FORCE_UNATTENDED, iHandle, 0
Else
If Text3.Text = A Then
If iHandle <> 0 Then
InternetHangUp iHandle, 0
iHandle = 0
End If
End If
End If
Else
If Check1.Value = 1 Then
Text1.Text = Time
A = TimeValue(Text1.Text)
If Text2.Text = A Then
InternetDial Me.hWnd, "163", INTERNET_AUTODIAL_FORCE_UNATTENDED, iHandle, 0
End If
End If
End If
End Sub
Private Sub Timer2_Timer()
显示当前时间
Text1.Text = Time
End Sub
|