Calcul heure de nuit

ocejade Messages postés 55 Date d'inscription jeudi 26 avril 2007 Statut Membre Dernière intervention 6 avril 2015 - 4 mai 2008 à 10:59
ocejade Messages postés 55 Date d'inscription jeudi 26 avril 2007 Statut Membre Dernière intervention 6 avril 2015 - 4 mai 2008 à 18:15
bonjour a vous les dieux
bon je suis a la recherche d une personne qui peut m expliquer comment calculer des heures de nuit
voila ma question quel code en vb6 utiliser pour calculer le nombre d heure ecoulé entre par exemple
22 h 00 a 10 h30 en sachant que les heures de nuit sont entre 22 h 00 et 6 h 30 . j ai dejat un peut de code voir la suite
Dim intheures As Integer
Dim intmintes As Integer
Dim intchiffreerreur As String
Dim strphoto As String

Private Sub ?_Click()
frmrelever.Show
End Sub

Private Sub cdmajouter_Click()
On Error GoTo erreur
Adodc1.Recordset.AddNew
txtheurestotal.Text = 0
txtminutestotal.Text = 0
strphoto = txtphoto.Text
imgphoto.Picture = LoadPicture(strphoto)
Exit Sub
erreur:
End Sub

Private Sub cdmconfirmer_Click()
On Error GoTo TrErreur
    Dim intcompteur As Integer
    For intcompteur = Me.Controls.Count - 1 To 0 Step -1
    Next intcompteur
    Adodc1.Recordset.Update
   Adodc1.Recordset!datene = DTPnee.Value
Adodc1.Recordset.Update
    Exit Sub
TrErreur:
   
End Sub

Private Sub cmdajouterheure_Click()
Dim intheurearr As Integer
Dim intheuredepart As Integer
Dim intheurefait As Integer
Dim intminarr As Integer
Dim intmindepart As Integer
Dim intminfait As Integer
Dim intmintemp As Integer
On Error GoTo erreur

'Verification des heure
If txtheurearr.Text "" Or txtheuredepart.Text "" Or txtminarr.Text = "" Or txtmindepart.Text = "" Then
    MsgBox "Une ou des cases Son vide", vbCritical, "ERREUR"
    Exit Sub
Else
    intheurearr = txtheurearr.Text
    intheuredepart = txtheuredepart.Text

    intheurearr = intheurearr * 60
    intheuredepart = intheuredepart * 60
If intheurearr < 0 Then
    MsgBox "Le chiffre entrer est négatif. Le programme va le remplacer par un chiffre positif!!!!"
    intheurearr = -intheurearr
    txtheurearr.Text = intheurearr / 60
End If
If intheurearr >= intheuredepart Then
    If intheurearr = intheuredepart Then
        If txtminarr.Text <> txtmindepart.Text Then
            intminarr = txtminarr.Text
            intmindepart = txtmindepart.Text
            txtheurea.Text = 0
        Else
            intheurefait = 1440
            txtheurea.Text = intheurefait / 60
        End If
    Else
        intheurefait = intheurearr - intheuredepart
        intheurefait = 1440 - intheurefait
        txtheurea.Text = intheurefait / 60
    End If
Else
    intheurefait = intheuredepart - intheurearr
    txtheurea.Text = intheurefait / 60
End If

'Vérification des minutes

intminarr = txtminarr.Text
intmindepart = txtmindepart.Text

If intminarr + intmindepart >= 60 Then
    If intminarr < intmindepart Then
    intminfait = intmindepart - intminarr
    ElseIf intminarr = intmindepart Then
        intminfait = 0
        txtheurea.Text = txtheurea + 1

   
   
    Else
   
    intminfait = (intminarr - intmindepart)
    intminfait = 60 - intminfait
   
    End If
   
Else
    If intminarr > intmindepart Then
    intminfait = (intminarr - intmindepart)
    intminfait = 60 - intminfait
    txtheurea.Text = txtheurea - 1
   
    Else
    intminfait = intmindepart - intminarr
    End If
End If
If intminfait < 0 Then
    intminfait = -intminfait
End If
If intminfait >= 60 Then
    intminfait = intminfait - 60
   txtheurea.Text = txtheurea.Text + 1
End If

txtmina.Text = intminfait
intheures = txtheurea.Text + (heures * 1)
intminutes = txtmina.Text + (minutes * 1)
txtheurestotal.Text = txtheurestotal.Text + intheures
txtminutestotal.Text = txtminutestotal.Text + intminutes

If txtminutestotal.Text >= 60 Then
    txtminutestotal.Text = txtminutestotal.Text - 60
    txtheurestotal.Text = txtheurestotal.Text + 1
End If

' Ici le programme vérifie le nombre d'heure total et si sa
' dépasse 35 heure le programe ajoute les heure de plus dans la case
' temp et demi et si c'est plus que 50 heure dans la case temp double

intheurefait = txtheurestotal.Text * 60
intminfait = txtminutestotal.Text
intheurefait = intheurefait + intminfait
If intheurefait >= 2100 Then
    intheurefait = txtheurestotal.Text * 60
   
    If intheurefait >= 3000 Then
       
   
           
       
    intheurefait = intheurefait - 3000
    txtheureregulier.Text = 35
    txtheuredemi.Text = 15
    txtminutesreg.Text = 0
    txtminutesdemi.Text = 0
    txtminutesdouble.Text = txtminutestotal.Text
    txtheuredouble.Text = intheurefait / 60
   
    Else
      
       
       
    intheurefait = intheurefait - 2100
    txtheureregulier.Text = 35
    txtminutesreg.Text = 0
    txtminutesdemi.Text = txtminutestotal.Text
    txtheuredemi.Text = intheurefait / 60
    End If
    Else
    intheurefait = txtheurestotal.Text * 60
    txtheureregulier.Text = intheurefait / 60
    txtminutesreg.Text = intminfait
End If

' le programme mais a jour la base de donné

 intminfait = txtminutestotal.Text
 Adodc1.Recordset!totalmin = intminfait
 Adodc1.Recordset.Update
 intheurefait = txtheurestotal.Text
 Adodc1.Recordset!totalheures = intheurefait
 Adodc1.Recordset.Update
 
 intminfait = txtminutesreg.Text
 Adodc1.Recordset!minreg = intminfait
 Adodc1.Recordset.Update
 intheurefait = txtheureregulier.Text
 Adodc1.Recordset!heurereg = intheurefait
 Adodc1.Recordset.Update
 
 intminfait = txtminutesdouble.Text
 Adodc1.Recordset!mindouble = intminfait
 Adodc1.Recordset.Update
 intheurefait = txtheuredouble.Text
 Adodc1.Recordset!heuredouble = intheurefait
 Adodc1.Recordset.Update
 
 intminfait = txtminutesdemi.Text
 Adodc1.Recordset!mindemi = intminfait
 Adodc1.Recordset.Update
 intheurefait = txtheuredemi.Text
 Adodc1.Recordset!heuredemi = intheurefait
 Adodc1.Recordset.Update
 
End If

Exit Sub
erreur:

End Sub
Private Sub cmdCalcul_Click()
On Error GoTo erreur
Dim inttauxhoraire As Single
Dim intheure As Single
Dim intregulier As Single
Dim intdemi As Single
Dim sgldouble As Single
Dim sglheuremin As Single
Dim sglreguliermin As Single
Dim sgldemimin As Single
Dim sgldoublemin As Single
Dim sglbrutregulier As Single
Dim sglbrutdemi As Single
Dim sglbrutdouble As Single
Dim sglbrut As Single
Dim sglheuretotal As Single
Dim sgldeducimpot As Single
Dim sgldeducrrq As Single
Dim sgldeducsyndicat As Single
Dim sgldeductotal As Single
Dim sglsalairenet As Single
Dim sglmintravailler As Single
Dim sglheuretravailler As SingleIf txtheureregulier.Text "" Or txtminutesreg.Text "" Or txtheuredemi.Text = "" Or txtminutesdemi.Text = "" Or txtminutesdouble.Text = "" Or txtheuredouble.Text = "" Then
    MsgBox "Une ou des cases Son vide", vbCritical, "ERREUR"
    Exit Sub
Else
        sglregulier = 0
        sgldouble = 0
        sgldemi = 0
        sglbrut = 0
        txtsalairebrut.Text = 0
        If txtheurestotal "0" And txtminutestotal "0" Then
    MsgBox "Vous devez entrer le nombre d'heure travailler", vbCritical, "ERREUR"
Else
        sglregulier = txtheureregulier.Text * 60
        sgldemi = txtheuredemi.Text * 60
        sgldouble = txtheuredouble.Text * 60
        sglreguliermin = txtminutesreg.Text
        sgldemimin = txtminutesdemi.Text
        sgldoublemin = txtminutesdouble.Text
        sglheuretravailler = txtheurestotal.Text * 60
        sglmintravailler = txtminutestotal.Text
        sglheure = sglmintravailler + sglheuretravailler
        sglheuretotal = sglregulier + sgldemi + sgldouble + sglreguliermin + sgldemimin + sgldoublemin
   
    If sglheuretotal = sglheure Then
        sgltauxhoraire = txttauxhoraire.Text
       
        sglbrutregulier = (sglregulier + sglreguliermin) * (sgltauxhoraire / 60)
       
        sglbrutdemi = ((sgldemi + sgldemimin) * ((sgltauxhoraire / 2) / 60))
        sglbrutdemi = sglbrutdemi + ((sgldemi + sgldemimin) * (sgltauxhoraire / 60))
       
        sglbrutdouble = (sgldouble + sgldoublemin) * ((sgltauxhoraire / 60) * 2)
        sglbrut = sglbrutdouble + sglbrutdemi + sglbrutregulier
        txtsalairebrut.Text = sglbrut & " ?"
        sgldeducimpot = (txtsalairebrut.Text * txtimpot.Text) / 100
        txtdeducimpot.Text = sgldeducimpot & " ?"
        sgldeducrrq = (txtsalairebrut.Text * txtRRQ.Text) / 100
        txtdeducrrq.Text = sgldeducrrq & " ?"
        sgldeducsyndicat = (txtsalairebrut.Text * txtsyndicat.Text) / 100
        txtdeducsyndicat.Text = sgldeducsyndicat & " ?"
        sgldeductotal = sgldeducsyndicat + sgldeducrrq + sgldeducimpot
        txtdeductotal.Text = sgldeductotal & " ?"
        sglsalairenet = sglbrut - sgldeductotal
        txtsalairenet.Text = sglsalairenet & " ?"
    Else
        MsgBox "Le nombre d'heure ne corresponde pas Veuillez Faire une Vérification!!!", vbCritical, "ERREUR"
    End If
End If
End If
Exit Sub
erreur:
MsgBox "Le salaire est trop elever pour ce logiciel"
End Sub

Private Sub cmdchangerimg_Click()

On Error GoTo loaderreur

cbdouvrir.Filter = "Gif (*.gif)|*.gif|Jpg (*.jpg)|*.jpg"
cbdouvrir.CancelError = True
cbdouvrir.ShowOpen

cbdouvrir.DialogTitle = "Choisissez un Fichier"

cbdouvrir.FilterIndex = 2
cbdouvrir.InitDir = "strphoto"

strphoto = cbdouvrir.FileName
imgphoto.Picture = LoadPicture(strphoto)
Adodc1.Recordset!Photo = strphoto
Adodc1.Recordset.Update
Exit Sub

loaderreur:
   
End Sub

Private Sub cmdDelete_Click()
On Error GoTo erreur
Adodc1.Recordset.Delete
        Adodc1.Recordset.MoveNext
        If Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveLast
        strphoto = txtphoto.Text
        imgphoto.Picture = LoadPicture(strphoto)
        Exit Sub
   
erreur:
Unload frmpay
frmpay.Show
End Sub

Private Sub cmddernier_Click()
On Error GoTo erreur
Adodc1.Recordset.MoveLast
strphoto = txtphoto.Text
imgphoto.Picture = LoadPicture(strphoto)
Exit Sub
erreur:
End Sub

Private Sub cmdeffacer_Click()
On Error GoTo TrErreur
txtheureregulier.Text = "0"
txtheuredemi.Text = "0"

txtheuredouble.Text = "0"
txtsalairebrut.Text = 0 & " ?"
txtheurestotal.Text = 0

txtdeducimpot.Text = 0 & " ?"
txtdeducrrq.Text = 0 & " ?"
txtdeducsyndicat.Text = 0 & " ?"
txtdeductotal.Text = 0 & " ?"
txtsalairenet.Text = 0 & " ?"
txtminutestotal.Text = 0
txtminutesreg.Text = "0"
txtminutesdemi.Text = "0"
txtminutesdouble.Text = "0"

Adodc1.Recordset!totalmin = txtminutestotal.Text
Adodc1.Recordset.Update

Adodc1.Recordset!totalheures = txtheurestotal.Text
Adodc1.Recordset.Update
TrErreur:
End Sub

Private Sub CmdOK_Click()
On Error GoTo erreurcolor
Dim strcouleur As String
If Cbofond.Text = "Rouge" Then
    frmpay.BackColor = vbRed
    fraemploye.BackColor = vbRed
    frabouton.BackColor = vbRed
    frasalaire.BackColor = vbRed
    Fraajouter.BackColor = vbRed
     fracalculsalaire.BackColor = vbRed
     fraoption.BackColor = vbRed
ElseIf Cbofond.Text = "Defaut" Then
    frmpay.BackColor = "&H8000000F"
    fraemploye.BackColor = "&H8000000F"
    frabouton.BackColor = "&H8000000F"
    frasalaire.BackColor = "&H8000000F"
    Fraajouter.BackColor = "&H8000000F"
    fracalculsalaire.BackColor = "&H8000000F"
    fraoption.BackColor = "&H8000000F"
ElseIf Cbofond.Text = "Bleu" Then
    frmpay.BackColor = vbBlue
    fraemploye.BackColor = vbBlue
    frabouton.BackColor = vbBlue
    frasalaire.BackColor = vbBlue
    Fraajouter.BackColor = vbBlue
    fracalculsalaire.BackColor = vbBlue
    fraoption.BackColor = vbBlue
Else
cbdcouleur.CancelError = True
cbdcouleur.ShowColor
strcouleur = cbdcouleur.Color
frmpay.BackColor = strcouleur
    fraemploye.BackColor = strcouleur
    frabouton.BackColor = strcouleur
    frasalaire.BackColor = strcouleur
    Fraajouter.BackColor = strcouleur
    fracalculsalaire.BackColor = strcouleur
    fraoption.BackColor = strcouleur
End If

erreurcolor:
End Sub

Private Sub cmdprecedent_Click()
On Error GoTo erreur
Adodc1.Recordset.MovePrevious
        If Adodc1.Recordset.BOF And Adodc1.Recordset.RecordCount > 0 Then Adodc1.Recordset.MoveNext
strphoto = txtphoto.Text
imgphoto.Picture = LoadPicture(strphoto)
Exit Sub
erreur:
End Sub

Private Sub cmdpremierenr_Click()
On Error GoTo erreur
Adodc1.Recordset.MoveFirst
strphoto = txtphoto.Text
imgphoto.Picture = LoadPicture(strphoto)
Exit Sub
erreur:
End Sub

Private Sub cmdsuivant_Click()
On Error GoTo erreur
Adodc1.Recordset.MoveNext
        If Adodc1.Recordset.EOF And Adodc1.Recordset.RecordCount > 0 Then Adodc1.Recordset.MoveLast
strphoto = txtphoto.Text
imgphoto.Picture = LoadPicture(strphoto)
Exit Sub
erreur:
End Sub

Private Sub fiche_Click()
Formid.Show
End Sub

Private Sub Form_Load()
On Error GoTo erreur
       
  
    Set txtphoto.DataSource = Adodc1
   
    
    
    
  
    txtphoto.DataField = "photo"
 
    strphoto = txtphoto.Text
    imgphoto.Picture = LoadPicture(strphoto)

    lbltime.Caption = Time
    Exit Sub
erreur:

End Sub

Private Sub mnufichieroption_Click()
frmoption.Show
End Sub

Private Sub fracalculsalaire_DragDrop(Source As Control, X As Single, Y As Single)

End Sub

Private Sub mnufichierprint_Click()
'frabouton.Visible = False
fraoption.Visible = False
Printer.Orientation = vbPRORLandscape
frmpay.PrintForm
'frabouton.Visible = True
fraoption.Visible = True
End Sub

Private Sub mnufichierquitter_Click()
End
End Sub

Private Sub mnuinfoAbout_Click()
frmabout.Show
End Sub

Private Sub tmrtime_Timer()
lbltime.Caption = Time
End Sub

Private Sub txtheurearr_Change()
intchiffreerreur = txtheurearr.TextIf intchiffreerreur "" Or IsNumeric(intchiffreerreur) False Then
    intchiffreerreur = ""
ElseIf intchiffreerreur > 24 Then
    MsgBox "Dans une journée il n'y a que 24 heure"
    intchiffreerreur = 0
End If
txtheurearr.Text = intchiffreerreur
End Sub

Private Sub txtheurearr_KeyPress(KeyAscii As Integer)
If KeyAscii = 44 Then
MsgBox "Les virgule son interdit dans cette partie", vbCritical, "ERREUR!!!!!!!!!!!!!"
txtheurearr.Text = ""
End If
End Sub

Private Sub txtheuredepart_Change()
intchiffreerreur = txtheuredepart.TextIf intchiffreerreur "" Or IsNumeric(intchiffreerreur) False Then
    intchiffreerreur = ""
ElseIf intchiffreerreur > 24 Then
    MsgBox "Dans une journée il n'y a que 24 heure"
    intchiffreerreur = 0
End If
txtheuredepart.Text = intchiffreerreur
End Sub

Private Sub txtheuredepart_KeyPress(KeyAscii As Integer)
If KeyAscii = 44 Then
MsgBox "Les virgule son interdit dans cette partie", vbCritical, "ERREUR!!!!!!!!!!!!!"
txtheuredepart.Text = ""
End If
End Sub

Private Sub txtimpot_Change()
intchiffreerreur = txtimpot.Text
If IsNumeric(intchiffreerreur) = False Then
    intchiffreerreur = ""

End If
txtimpot.Text = intchiffreerreur
End Sub

Private Sub txtminarr_Change()
intchiffreerreur = txtminarr.Text
erreur
txtminarr.Text = intchiffreerreur
End Sub

Private Sub txtminarr_KeyPress(KeyAscii As Integer)
If KeyAscii = 44 Then
MsgBox "Les virgule son interdit dans cette partie", vbCritical, "ERREUR!!!!!!!!!!!!!"
txtminarr.Text = ""
End If

End Sub

Private Sub txtmindepart_Change()
intchiffreerreur = txtmindepart.Text
erreur
txtmindepart.Text = intchiffreerreur
End Sub

Function erreur()If intchiffreerreur "" Or IsNumeric(intchiffreerreur) False Then
intchiffreerreur = ""
Else
If intchiffreerreur > 59 Then
MsgBox "Dans un heure il y a que 60 minute"
intchiffreerreur = ""
End If
End If
End Function

Private Sub txtmindepart_KeyPress(KeyAscii As Integer)
If KeyAscii = 44 Then
MsgBox "Les virgule son interdit dans cette partie", vbCritical, "ERREUR!!!!!!!!!!!!!"
txtmindepart.Text = ""
End If
End Sub

Private Sub txtRRQ_Change()
intchiffreerreur = txtRRQ.Text
If IsNumeric(intchiffreerreur) = False Then
    intchiffreerreur = ""

End If
txtRRQ.Text = intchiffreerreur
End Sub

Private Sub txtsyndicat_Change()
intchiffreerreur = txtsyndicat.Text
If IsNumeric(intchiffreerreur) = False Then
    intchiffreerreur = ""

End If

txtsyndicat.Text = intchiffreerreur
End Sub

Private Sub txttauxhoraire_Change()
intchiffreerreur = txttauxhoraire.Text
If IsNumeric(intchiffreerreur) = False Then
    intchiffreerreur = ""

End If
txttauxhoraire.Text = intchiffreerreur
End Sub
je vous attend pour progresser en vous remercien d avance

2 réponses

cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
4 mai 2008 à 13:48
 Bonjour,

Cette source n'est pas en vb6, mais utilise les fonctions FormatDateTime, TimeSerial, DateDiff,
Hour et Minute
pour calculer les heures de travail de nuit (de 22h00 à
06h00).

jean-marc
0
ocejade Messages postés 55 Date d'inscription jeudi 26 avril 2007 Statut Membre Dernière intervention 6 avril 2015
4 mai 2008 à 18:15
MERCI JEAN MARC
COMME TU A PUS LE VOIR MON PROG EST DEJA PAS MAL
MAIS LE CODAGE D HEURE C EST PAS MON TRUC ALORS LA FONCTION AUTOMATIQUE JE VEUT METTRE EN PLACE SERVIRAS A CALCULER LES HEURES DE NUIT PAR EXEMPLE 23 H 00 A 10 H 00 11H 00 DE TRAVAIL NORMAL ET LES HEURES ENTRE 22 H 00 ET 6 H 00 7 H 00 DE NUIT

TA SOURCE NE M EXPLIQUE PAS GRAND CHOSE
SA NE SERT A RIEN QUE JE RECOPIE UNE SOURCE QUE JE NE COMPREND PAS

J ESPERE AVOIR UN AUTRE MESSAGE DE TA PAR
0
Rejoignez-nous