Je commence en vb et mon âge est 1930 alors que je veux 30.Je comprends pas pouquoi mon code fonctionne pas???? fais pas + 1900 ou + 2000
merci!!
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Private Sub btnValider_Click(sender As System.Object, e As System.EventArgs) Handles btnValider.Click
 
            Dim strCode As String
        Dim intJour As Integer
        Dim intMois As Integer
        Dim intAnnee As Integer
        Dim strinitiales As String
        Dim strDate As String
 
 
        strCode = txtCodePerm.Text 'code permanent au complet
        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....
        strinitiales = txtCodePerm.Text.ToUpper.Substring(3, 1) + txtCodePerm.Text.ToUpper.Substring(0, 1) 'pour obtenir les initiales en majuscule
 
        My.Computer.FileSystem.WriteAllText(".\Code.txt", txtCodePerm.Text, False) '.\ pour repertoire en cours, cré un fichier text pour stocker données
        'false=remplacer true=ajouter
 
        If intMois > 50 Then
            lblRepSexe.Text = "Féminin"
            intMois = intMois - 50
        Else
            lblRepSexe.Text = "Masculin"
            lblRepInit.Text = strinitiales
        End If
'===============ICI POUR CALCULER ÂGE============>
        If CBool(CInt(CInt(intJour <= 93) >= 63)) Then
            intAnnee = 2000 + CInt(intAnnee)
        ElseIf CBool(CInt(CInt(intJour <= 31) >= 1)) Then
            intAnnee = 1900 + CInt(intAnnee)
        End If
 
        strDate = CStr(intJour) + CStr(intMois) + CStr(intAnnee)
        lblRepDatNaiss.Text = CStr(intJour) + "/" + fncMois(intMois) + "/" + CStr(intAnnee)
 
        Dim intage As String
        intage = CStr(Now.Year - intAnnee)
        If Now.Month < intMois Then
            intage = CStr(CDbl(intage) - 1)
 
 
 
            If txtCodePerm.Text.Length <> 12 Then 'le code doit contenir 12 caractères obligatoirement
                MsgBox("Entrez 12 caractères, 4 lettres suivies de 8 chiffres")
            ElseIf UCase(Mid(txtCodePerm.Text, 5, 1)) >= "A" And UCase(Mid(txtCodePerm.Text, 5, 1)) <= "Z" Then 
                MsgBox("Pour les huits derniers caractères, entrez des chiffres seulements")
            ElseIf UCase(Mid(txtCodePerm.Text, 6, 1)) >= "A" And UCase(Mid(txtCodePerm.Text, 6, 1)) <= "Z" Then
                MsgBox("Pour les huits derniers caractères, entrez des chiffres seulements")
            ElseIf UCase(Mid(txtCodePerm.Text, 7, 1)) >= "A" And UCase(Mid(txtCodePerm.Text, 7, 1)) <= "Z" Then
                MsgBox("Pour les huits derniers caractères, entrez des chiffres seulements")
            ElseIf UCase(Mid(txtCodePerm.Text, 8, 1)) >= "A" And UCase(Mid(txtCodePerm.Text, 8, 1)) <= "Z" Then
                MsgBox("Pour les huits derniers caractères, entrez des chiffres seulements")
            ElseIf UCase(Mid(txtCodePerm.Text, 9, 1)) >= "A" And UCase(Mid(txtCodePerm.Text, 9, 1)) <= "Z" Then
                MsgBox("Pour les huits derniers caractères, entrez des chiffres seulements")
            ElseIf UCase(Mid(txtCodePerm.Text, 10, 1)) >= "A" And UCase(Mid(txtCodePerm.Text, 10, 1)) <= "Z" Then
                MsgBox("Pour les huits derniers caractères, entrez des chiffres seulements")
            ElseIf UCase(Mid(txtCodePerm.Text, 11, 1)) >= "A" And UCase(Mid(txtCodePerm.Text, 11, 1)) <= "Z" Then
                MsgBox("Pour les huits derniers caractères, entrez des chiffres seulements")
            ElseIf UCase(Mid(txtCodePerm.Text, 12, 1)) >= "A" And UCase(Mid(txtCodePerm.Text, 12, 1)) <= "Z" Then
                MsgBox("Pour les huits derniers caractères, entrez des chiffres seulements")
 
 
            End If
 
            If intMois < 1 Or intMois > 12 Then 'les chiffres pour le mois sont de 1 à 12 obligatoirement
                MsgBox("Erreur,ceci n'est pas un mois valide, entrez de 1 à 12")
 
            End If
 
 
 
 
        End If
        lblRepAge.Text = CStr(intage)
 
        lblRepInit.Text = txtCodePerm.Text.ToUpper.Substring(3, 1) + txtCodePerm.Text.ToUpper.Substring(0, 1)
 
 
    End Sub
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
    Private Sub btnDernier_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDernier.Click 'bouton pour afficher dernier code permanent SOURCE= dans projet waAccesFichier
        Dim strFichier As String 'tampon pour lecture
        strFichier = My.Computer.FileSystem.ReadAllText(".\Code.txt")
        MsgBox(strFichier.ToUpper)
 
 
    End Sub
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
    Private Function fncMois(ByVal intchangerMois As Integer) As String ' fonction qui "transformera" le nombre compris dans intMois pour le mettre en mois en lettre, (aidé par Jonathan)
        Dim strNomMois As String = String.Empty
        Select Case (intchangerMois)
            Case 1
                strNomMois = " janvier "
            Case 2
                strNomMois = " février "
            Case 3
                strNomMois = " mars "
            Case 4
                strNomMois = " avril "
            Case 5
                strNomMois = " mai "
            Case 6
                strNomMois = " juin "
            Case 7
                strNomMois = " juillet "
            Case 8
                strNomMois = " août "
            Case 9
                strNomMois = " septembre"
            Case 10
                strNomMois = " octobre"
            Case 11
                strNomMois = " novembre"
            Case 12
                strNomMois = " décembre"
 
 
        End Select
        Return strNomMois
 
    End Function