Advertisement
Guest User

VB.net noob

a guest
Nov 9th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 2.23 KB | None | 0 0
  1. Public Class Form1
  2.  
  3.     Private Sub btnQuitter_Click(sender As Object, e As EventArgs) Handles btnQuitter.Click
  4.         End
  5.     End Sub
  6.  
  7.  
  8.     Private Sub btnAfficher_Click(sender As Object, e As EventArgs) Handles btnAfficher.Click
  9.  
  10.         If txtNAM.Text.Length = 12 Then
  11.  
  12.             Dim lettre As String = txtNAM.Text.Substring(0, 4)
  13.             Dim annee As String = txtNAM.Text.Substring(4, 4)
  14.             Dim mois As String = txtNAM.Text.Substring(8, 2)
  15.             Dim jour As String = txtNAM.Text.Substring(10, 2)
  16.  
  17.             Dim booLettre As Boolean = True
  18.             For Each elem In lettre
  19.                 If Not Char.IsLetter(elem) Then
  20.                     booLettre = False
  21.                 End If
  22.             Next
  23.  
  24.             If booLettre = False Then
  25.                 MsgBox("Il manque un caractère. Vous devez inscrire les 3 premier caractère de votre nom de famille et la première lettre de votre prénom", MsgBoxStyle.Exclamation, "Erreur")
  26.             End If
  27.  
  28.             If CInt(annee) < 1920 Or CInt(annee) > 2017 Then
  29.                 MsgBox("L'année de naissance doit être entre 1920 et 2017", MsgBoxStyle.Exclamation, "Erreur")
  30.             End If
  31.  
  32.             If CInt(mois) < 1 Or CInt(mois) > 12 Then
  33.                 MsgBox("Le mois de naissance est invalide", MsgBoxStyle.Exclamation, "Erreur")
  34.             End If
  35.  
  36.             Select Case CInt(mois)
  37.                 Case 1, 3, 5, 7, 8, 10, 12
  38.                     If CInt(jour) > 31 Or CInt(jour) < 0 Then
  39.                         MsgBox("Le jour de naissance est invalide", MsgBoxStyle.Exclamation, "Erreur")
  40.                     End If
  41.                 Case 2
  42.                     If CInt(jour) > 28 Or CInt(jour) < 0 Then
  43.                         MsgBox("Le jour de naissance est invalide", MsgBoxStyle.Exclamation, "Erreur")
  44.                     End If
  45.                 Case Else
  46.                     If CInt(jour) > 30 Or CInt(jour) < 0 Then
  47.                         MsgBox("Le jour de naissance est invalide", MsgBoxStyle.Exclamation, "Erreur")
  48.                     End If
  49.             End Select
  50.         Else
  51.             MsgBox("Le Numéro d'assurance maladie est invalide", MsgBoxStyle.Exclamation, "Erreur")
  52.         End If
  53.  
  54.     End Sub
  55. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement