Exercice Visual Basic : Espace national du Livre
Rédigé par GC Team, Publié le 07 Janvier 2012, Mise à jour le Samedi, 17 Décembre 2022 15:22![](/images/thumb/146/default.png)
Participez au vote ☆☆☆☆☆★★★★★
Ecrire le programme qui permet de réaliser l'interface suivante:
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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
Public Class cancel Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles h.CheckedChanged If sender Is h Then sel(Qteh, h) End If End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim a = MsgBox("voulez vouz vraiment nous quitter ?", MsgBoxStyle.YesNo Or MsgBoxStyle.Information, "Quitter..!!!") If a = vbYes Then End End If End Sub Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m.Enter End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Qteh.TextChanged End Sub Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Qtes.TextChanged End Sub Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles remise.TextChanged End Sub Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles map.TextChanged End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim remis As Single Dim mnt As Single If h.Checked = True Then remise.Text = calcrem(CInt(Qteh.Text)) mnt = 100 * CInt(Qteh.Text) End If If s.Checked = True Then remise.Text = calcrem(CInt(Qtes.Text)) mnt = 120 * CInt(Qtes.Text) End If If h.Checked And s.Checked Then remise.Text = calcrem(CInt(Qteh.Text) + CInt(Qtes.Text)) mnt = 120 * CInt(Qtes.Text) + 100 * CInt(Qteh.Text) End If map.Text = mnt * (1 - remise.Text) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click remise.ResetText() Qteh.ResetText() Qtes.ResetText() map.ResetText() remise.Text = 0 Qteh.Text = 0 Qtes.Text = 0 map.Text = 0 Qtes.Visible = False Qteh.Visible = False h.Checked = False s.Checked = False End Sub Public Function calcrem(ByVal qte As Integer) As Single Dim r As Single 'une variable dans laquelle on va calculer la remise If qte >= 20 Then r = 10 / 100 ElseIf qte >= 10 Then r = 8 / 100 ElseIf qte >= 5 Then r = 5 / 100 Else r = 0 End If Return r End Function Private Sub sel(ByVal a As TextBox, ByVal b As CheckBox) a.Visible = b.Checked a.Text = 0 a.Focus() a.SelectionStart = 0 End Sub Private Sub s_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles s.CheckedChanged If sender Is s Then sel(Qtes, s) End If End Sub End Class |