- 'functions nécessaires pour se connecter, se deconnecter et vérifier la connection
- Const Internet_Autodial_Force_Unattended As Long = 2
- 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 Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long
-
- 'affiche l' heure...
- Private Sub Timer1_Timer()
- heure.Caption = Format(Time, "hh:mm")
- End Sub
-
- 'pour fermer les boucles lorsque l' on quite le programme sans avoir cliquer sur arrêter
- Private Sub Form_Unload(Cancel As Integer)
- End
- End Sub
-
- 'le bouton pour lancer ou arrêter le programme
- Private Sub go_Click()
- If (go.Caption = "Démarrer") Then
- go.Caption = "Arrêter"
- heurech.Enabled = False
- heurecm.Enabled = False
- heuredh.Enabled = False
- heuredm.Enabled = False
- prog
- Else
- deconnection = InternetAutodialHangup(0&)
- go.Caption = "Démarrer"
- heurech.Enabled = True
- heurecm.Enabled = True
- heuredh.Enabled = True
- heuredm.Enabled = True
- temps.Caption = "Arrêter"
- End If
- End Sub
-
- 'le programme
- Private Sub prog()
- Dim hc, hd, tr, heure As String
- hc = heurech.Text * 3600 + heurecm.Text * 60
- hd = heuredh.Text * 3600 + heuredm.Text * 60
- Do While go.Caption = "Arrêter"
- DoEvents
- heure = Format(Timer, "####0")
- If (hc >= heure) Then
- tr = hc - heure & "secondes avant connection"
- Else
- tr = 86400 + hc - heure & "secondes avant connection"
- End If
- temps.Caption = tr
- If (tr = "0secondes avant connection") Then
- temps.Caption = "Connection..."
- connection: Connect = InternetAutodial(Internet_Autodial_Force_Unattended, 0&)
- Dim check As Boolean
- check = InternetGetConnectedState(0&, 0&)
- If (check = True) Then
- temps.Caption = "Connecter !!!"
- Do While go.Caption = "Arrêter"
- DoEvents
- heure = Format(Timer, "####0")
- If (hd > heure) Then
- temps.Caption = hd - heure & "secondes avant déconnection"
- Else
- deconnection = InternetAutodialHangup(0&)
- go.Caption = "Démarrer"
- heurech.Enabled = True
- heurecm.Enabled = True
- heuredh.Enabled = True
- heuredm.Enabled = True
- temps.Caption = Terminer
- End If
- Loop
- Else
- GoTo connection
- End If
- End If
- Loop
- End Sub
-
'functions nécessaires pour se connecter, se deconnecter et vérifier la connection
Const Internet_Autodial_Force_Unattended As Long = 2
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 Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long
'affiche l' heure...
Private Sub Timer1_Timer()
heure.Caption = Format(Time, "hh:mm")
End Sub
'pour fermer les boucles lorsque l' on quite le programme sans avoir cliquer sur arrêter
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
'le bouton pour lancer ou arrêter le programme
Private Sub go_Click()
If (go.Caption = "Démarrer") Then
go.Caption = "Arrêter"
heurech.Enabled = False
heurecm.Enabled = False
heuredh.Enabled = False
heuredm.Enabled = False
prog
Else
deconnection = InternetAutodialHangup(0&)
go.Caption = "Démarrer"
heurech.Enabled = True
heurecm.Enabled = True
heuredh.Enabled = True
heuredm.Enabled = True
temps.Caption = "Arrêter"
End If
End Sub
'le programme
Private Sub prog()
Dim hc, hd, tr, heure As String
hc = heurech.Text * 3600 + heurecm.Text * 60
hd = heuredh.Text * 3600 + heuredm.Text * 60
Do While go.Caption = "Arrêter"
DoEvents
heure = Format(Timer, "####0")
If (hc >= heure) Then
tr = hc - heure & "secondes avant connection"
Else
tr = 86400 + hc - heure & "secondes avant connection"
End If
temps.Caption = tr
If (tr = "0secondes avant connection") Then
temps.Caption = "Connection..."
connection: Connect = InternetAutodial(Internet_Autodial_Force_Unattended, 0&)
Dim check As Boolean
check = InternetGetConnectedState(0&, 0&)
If (check = True) Then
temps.Caption = "Connecter !!!"
Do While go.Caption = "Arrêter"
DoEvents
heure = Format(Timer, "####0")
If (hd > heure) Then
temps.Caption = hd - heure & "secondes avant déconnection"
Else
deconnection = InternetAutodialHangup(0&)
go.Caption = "Démarrer"
heurech.Enabled = True
heurecm.Enabled = True
heuredh.Enabled = True
heuredm.Enabled = True
temps.Caption = Terminer
End If
Loop
Else
GoTo connection
End If
End If
Loop
End Sub