Exercice Visual Basic : Voyage
Rédigé par GC Team, Publié le 07 Janvier 2012, Mise à jour le Samedi, 17 Décembre 2022 16:36
Participez au vote ☆☆☆☆☆★★★★★
Réalier l'Interface suivante selon les Etapes:
- Laboutton OK est désactiver;
- Lorsqu'on entre l'Intitulé le Boutton OK est alors activée et l'intitulé s'écrit automatiquement au titre de la Windows Form;
- Aprés clique sur Boutton OK un MessageBox s'affiche avec les Informations du Formulaire;
- Aprés clique sur Boutton OK du MessageBo un autre MessageBo s'affiche avec la demande de confirmation ou l'annulation des données

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 81 82 83 |
Public Class Form1 Dim d, frm, msg As String Dim l, pl, insc As Integer Dim dep, arr As Date Private Sub NumericUpDown2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown2.ValueChanged pl = NumericUpDown1.Value insc = NumericUpDown2.Value l = pl - insc Label7.Text = "Libres : " & l End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged Me.Text = "Voyage : " & TextBox1.Text.Trim frm = Me.Text If TextBox1.Text "" Then Button2.Enabled = True Else Button2.Enabled = False End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load NumericUpDown1.Minimum = 0 NumericUpDown2.Minimum = 0 DateTimePicker1.MinDate = Now DateTimePicker2.MinDate = Now Button2.Enabled = False End Sub Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged NumericUpDown2.Maximum = NumericUpDown1.Value pl = NumericUpDown1.Value insc = NumericUpDown2.Value l = pl - insc Label7.Text = "Libres : " & l End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Close() End Sub Private Sub DateTimePicker2_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker2.ValueChanged dep = Format(DateTimePicker1.Value, "dd/MM/yy") arr = Format(DateTimePicker2.Value, "dd/MM/yy") If arr < dep Then MsgBox("Date Invalide!") DateTimePicker2.MinDate = dep d = 0 Else DateTimePicker2.MinDate = dep End If d = (arr.Day - dep.Day).ToString Label4.Text = d & " jour(s)" End Sub Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged dep = Format(DateTimePicker1.Value, "dd/MM/yy") arr = Format(DateTimePicker2.Value, "dd/MM/yy") If arr < dep Then MsgBox("Date Arrivée Invalide!") DateTimePicker2.MinDate = dep d = 0 Else DateTimePicker2.MinDate = dep End If d = (arr.Day - dep.Day).ToString Label4.Text = d & " jour(s)" End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click msg = "Départ : " & dep & vbCrLf & "Arrivée : " & arr & vbCrLf & "Durée : " & d & " jour(s)" & vbCrLf & "Places : " & pl & vbCrLf & "Inscrits : " & insc & vbCrLf & "Libres : " & l & vbCrLf MsgBox(msg, MsgBoxStyle.Information, frm) If MessageBox.Show(msg & vbCrLf & "Voulez-vous enregistrer?", frm, MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button1) = Windows.Forms.DialogResult.Yes Then TextBox1.Text = "" DateTimePicker1.Value = Now DateTimePicker2.Value = DateAdd(DateInterval.Day, 1, Now) 'Ajouter un jour à la date system NumericUpDown1.Value = 0 NumericUpDown2.Value = 0 Label4.Text = "###" Label7.Text = "###" End If End Sub End Class |
