1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| Public Class frmMain
Private Sub EffacerLabelsDeReponse()
lblRepAge.Text = ""
lblRepDatNaiss.Text = ""
lblRepInit.Text = ""
lblRepSexe.Text = ""
End Sub
Private Sub btnValider_Click(sender As System.Object, e As System.EventArgs) Handles btnValider.Click
Dim intJour As Integer
Dim intMois As Integer
Dim intAnnee As Integer
Dim intNbCarac As Integer 'Détermine le nombre de caractères
Dim intinitiales As String
Dim strDate As String
intNbCarac = fncCompteLettres(txtCodePerm.Text) + fncCompteChiffres(txtCodePerm.Text)
Call EffacerLabelsDeReponse()
If intNbCarac < 12 Or intNbCarac > 12 Then
MsgBox("Veuillez entrer douze caractères, quatres lettres suivies de huit chiffres.")
ElseIf fncCompteLettres(txtCodePerm.Text.Substring(4, 8)) > 0 Then
MsgBox("Veuillez entrer des chiffres pour les huit derniers caractères.")
ElseIf fncCompteChiffres(txtCodePerm.Text.Substring(0, 4)) > 0 Then
MsgBox("Veuillez entrer des lettres pour les quatres premiers caractères.")
Call EffacerLabelsDeReponse()
Else
My.Computer.FileSystem.WriteAllText(".\CodePermanent.txt", txtCodePerm.Text.ToUpper, False)
intinitiales = txtCodePerm.Text.ToUpper.Substring(3, 1) + txtCodePerm.Text.ToUpper.Substring(0, 1) 'pour obtenir les initiales en majuscule
strDate = CStr(intJour) + CStr(intMois) + CStr(intAnnee)
intJour = CInt(txtCodePerm.Text.Substring(4, 2)) 'pour avoir le jour
intMois = CInt(txtCodePerm.Text.Substring(6, 2)) ' pour avoir le mois SAUF si femme -50
intAnnee = CInt(txtCodePerm.Text.Substring(8, 2)) 'année, falloir calculer si 19... ou 20....
If CInt(intJour) <= 93 And CInt(intJour) >= 63 Then 'pour jour de qqn né en 2000 ou plus,les jours seront de 63 à 93 et on soustrait 62.
intAnnee = 2000 + CInt(intAnnee)
intJour = CInt(intJour) - 62
ElseIf CInt(intJour) <= 31 And CInt(intJour) >= 1 Then 'pour jour de qqn né en 1999 ou avant, les jours sont de 1 à 31.
intAnnee = 1900 + CInt(intAnnee)
Else
MsgBox("Erreur,ceci n'est pas n'est pas un jour valide.")
Call EffacerLabelsDeReponse()
End If |
Partager