IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

CodePermanent en vb


Sujet :

VB.NET

  1. #1
    Candidat au Club
    Inscrit en
    Mars 2013
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Mars 2013
    Messages : 4
    Points : 3
    Points
    3
    Par défaut CodePermanent en vb
    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

  2. #2
    Membre éprouvé
    Profil pro
    Inscrit en
    Octobre 2006
    Messages
    665
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2006
    Messages : 665
    Points : 1 161
    Points
    1 161
    Par défaut
    Bonsoir,
    sauf erreur, on ne rentre jamais dans ces boucles :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
            '===============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

  3. #3
    Candidat au Club
    Inscrit en
    Mars 2013
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Mars 2013
    Messages : 4
    Points : 3
    Points
    3
    Par défaut re
    merci....
    en fait avant que vb corrige en cbool, j'écrivais:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    if cint(intjour)<=31>=1 then
    intannee=cint(intannee+1900)
    elseif cint(intjour)<=93>=62 then
    intannee=cint(intannee+2000)
    c'est la formule que j'ai besoin mais vb veut pas,j'ai essayé plus de () mais veut pas plus...pourquoi??
    merci encore

  4. #4
    Membre éprouvé
    Profil pro
    Inscrit en
    Octobre 2006
    Messages
    665
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2006
    Messages : 665
    Points : 1 161
    Points
    1 161
    Par défaut
    Ça ressemblera à ça plutôt :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
            '===============ICI POUR CALCULER ÂGE============>
            If intJour <= 93 And intJour >= 63 Then
                intAnnee = 2000 + CInt(intAnnee)
            ElseIf intJour <= 31 And intJour >= 1 Then
                intAnnee = 1900 + CInt(intAnnee)
            End If
    A réviser, les opérateurs Visual Basic.

  5. #5
    Candidat au Club
    Inscrit en
    Mars 2013
    Messages
    4
    Détails du profil
    Informations forums :
    Inscription : Mars 2013
    Messages : 4
    Points : 3
    Points
    3
    Par défaut
    merci tellement!!

+ Répondre à la discussion
Cette discussion est résolue.

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo