Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !

UN CONTRÔLE HORLOGE BASIQUE


Information sur la source

Catégorie :Date & Heure Niveau : Débutant Date de création : 06/09/2003 Date de mise à jour : 06/09/2003 11:53:38 Vu / téléchargé: 2 595 / 322

Note :
5 / 10 - par 1 personne
5,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10

Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note

Description

Puisque je n'ai pas trouvé de Contrôle ActiveX pour l'heure (comme "Microsoft Calendar Control" pour la date), voici un ocx pour l'heure.

Personnalisez le selon vos besoins et vos préférences. Il n'y a pas beaucoup de propriétés (Hour et Minute) car c'est mon premier OCX.
 

Source

  • '----------------- Contrôles :
  • 2 textbox : Heure et minute (TxtHeure et txtMinute)
  • 4 command : HeurePlus, HeureMoins, MinutePlus, MinuteMoins
  • '----------------- Code :
  • Option Explicit
  • Private Sub HeureMoins_Click()
  • With TxtHeure
  • If .Text = "" Then
  • .Text = "0"
  • End If
  • If .Text = "0" Then
  • .Text = "23"
  • Else
  • .Text = .Text - 1
  • End If
  • End With
  • End Sub
  • Private Sub HeurePlus_Click()
  • With TxtHeure
  • If .Text = "" Then
  • .Text = "0"
  • End If
  • If .Text = "23" Then
  • .Text = "0"
  • Else
  • .Text = .Text + 1
  • End If
  • End With
  • End Sub
  • Private Sub MinuteMoins_Click()
  • With TxtMinute
  • If .Text = "" Then
  • .Text = "00"
  • End If
  • If .Text = "00" Then
  • .Text = "59"
  • Else
  • .Text = .Text - 1
  • End If
  • End With
  • Call Zero
  • End Sub
  • Private Sub MinutePlus_Click()
  • With TxtMinute
  • If .Text = "" Then
  • .Text = "00"
  • End If
  • If .Text = "59" Then
  • .Text = "00"
  • Else
  • .Text = .Text + 1
  • End If
  • End With
  • Call Zero
  • End Sub
  • Private Sub TxtHeure_Change()
  • Call VerifierHeure
  • End Sub
  • Private Sub TxtMinute_Change()
  • Call VerifierMinute
  • End Sub
  • Private Sub TxtMinute_KeyPress(KeyAscii As Integer)
  • If KeyAscii = 13 Then
  • Call Zero
  • End If
  • End Sub
  • Private Sub UserControl_Resize()
  • UserControl.Width = 3345
  • UserControl.Height = 1665
  • End Sub
  • Public Property Get Hour() As String
  • Hour = TxtHeure.Text
  • End Property
  • Public Property Get Minute() As String
  • Minute = TxtMinute.Text
  • End Property
  • Sub VerifierHeure()
  • If Not (IsNumeric(TxtHeure.Text)) Then
  • GoTo fin
  • End If
  • If TxtHeure.Text < 0 Then
  • GoTo fin
  • End If
  • If TxtHeure.Text > 23 Then
  • GoTo fin
  • End If
  • Exit Sub
  • fin:
  • MsgBox "Valeur incorrecte", vbCritical
  • TxtHeure.Text = "12"
  • End Sub
  • Sub VerifierMinute()
  • If Not (IsNumeric(TxtMinute.Text)) Then
  • GoTo fin
  • End If
  • If TxtMinute.Text < 0 Then
  • GoTo fin
  • End If
  • If TxtMinute.Text > 59 Then
  • GoTo fin
  • End If
  • Exit Sub
  • fin:
  • MsgBox "Valeur incorrecte", vbCritical
  • TxtMinute.Text = "00"
  • End Sub
  • Sub Zero()
  • If Len(TxtMinute.Text) = 1 Then
  • TxtMinute.Text = "0" & TxtMinute.Text
  • End If
  • End Sub
'----------------- Contrôles :

2 textbox : Heure et minute (TxtHeure et txtMinute)
4 command : HeurePlus, HeureMoins, MinutePlus, MinuteMoins



'----------------- Code :

Option Explicit

Private Sub HeureMoins_Click()

With TxtHeure

    If .Text = "" Then
        .Text = "0"
    End If

    If .Text = "0" Then
        .Text = "23"
    Else
        .Text = .Text - 1
    End If
    
End With

End Sub

Private Sub HeurePlus_Click()
   
With TxtHeure

    If .Text = "" Then
        .Text = "0"
    End If

    If .Text = "23" Then
        .Text = "0"
    Else
        .Text = .Text + 1
    End If
    
End With

End Sub

Private Sub MinuteMoins_Click()

With TxtMinute

    If .Text = "" Then
        .Text = "00"
    End If

    If .Text = "00" Then
        .Text = "59"
    Else
        .Text = .Text - 1
    End If
    
End With

Call Zero

End Sub

Private Sub MinutePlus_Click()

With TxtMinute

    If .Text = "" Then
        .Text = "00"
    End If

    If .Text = "59" Then
        .Text = "00"
    Else
        .Text = .Text + 1
    End If
    
End With

Call Zero

End Sub



Private Sub TxtHeure_Change()
    Call VerifierHeure
End Sub

Private Sub TxtMinute_Change()
    Call VerifierMinute
End Sub

Private Sub TxtMinute_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then
        Call Zero
    End If
End Sub

Private Sub UserControl_Resize()
    UserControl.Width = 3345
    UserControl.Height = 1665
End Sub



Public Property Get Hour() As String
    Hour = TxtHeure.Text
End Property


Public Property Get Minute() As String
    Minute = TxtMinute.Text
End Property


Sub VerifierHeure()
    
    If Not (IsNumeric(TxtHeure.Text)) Then
        GoTo fin
    End If
    
    If TxtHeure.Text < 0 Then
        GoTo fin
    End If
    
    If TxtHeure.Text > 23 Then
        GoTo fin
    End If
   
    Exit Sub
    
fin:

        MsgBox "Valeur incorrecte", vbCritical
        TxtHeure.Text = "12"
    
End Sub

Sub VerifierMinute()

If Not (IsNumeric(TxtMinute.Text)) Then
        GoTo fin
    End If
    
    If TxtMinute.Text < 0 Then
        GoTo fin
    End If
    
    If TxtMinute.Text > 59 Then
        GoTo fin
    End If
    
   
    Exit Sub
    
fin:

        MsgBox "Valeur incorrecte", vbCritical
        TxtMinute.Text = "00"


End Sub



Sub Zero()

    If Len(TxtMinute.Text) = 1 Then
        TxtMinute.Text = "0" & TxtMinute.Text
    End If
    
End Sub

Fichier Zip

Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip

Commentaires et avis

Aucun commentaire pour le moment.

Ajouter un commentaire



Nos sponsors

Sondage...

CalendriCode

Janvier 2009
LMMJVSD
   1234
567891011
12131415161718
19202122232425
262728293031 

Consulter la suite du CalendriCode



Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel BAÏSE, Merci à Vincent pour ses précieux conseils
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés
Temps d'éxécution de la page : 0,218 sec

Google Coop CodeS-SourceS Google Coop CodeS-SourceS


Certaines images présentes sur le site (notament certains avatars) sont issues des collections IconShock, donc si vous souhaitez utiliser ces icons vous devez les acheter, ne les copiez pas et ne utilisez pas dans vos sites et applications sans les avoir commandé.