Exercice VB: Interface calculator
Rédigé par GC Team, Publié le 03 Janvier 2012, Mise à jour le Vendredi, 16 Décembre 2022 22:22Participez au vote ☆☆☆☆☆★★★★★
Ecrire le programme qui permet de réaliser l'interface suivante:
- Ajouter une Méthode qui permet de vérifier si lle variable entré dans les zones de textes 1 et 2 sont un caractère ou un nombre
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 |
Public Class Form1 Private Sub btncalcul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalcul.Click If Not IsNumeric(TextBox1.Text) Then MsgBox("vous devez saisir un nomdre valide") : TextBox1.Focus() : Exit Sub If Not IsNumeric(TextBox2.Text) Then MsgBox("vous devez saisir un nomdre valide") : TextBox2.Focus() : Exit Sub lblsom.Text = CDbl(TextBox1.Text) + CDbl(TextBox2.Text) End Sub Private Sub btnvider_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnvider.Click TextBox1.Text = "" TextBox2.Text = "" lblsom.Text = "" End Sub Private Sub btnqter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnqter.Click If MessageBox.Show("voulez vous quiter l'application", "fin", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then End End Sub Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress 'Select Case e.KeyChar ' Case "0" To "9" ' Case Else ' e.Handled = True 'End Select 'Label4.Text = e.KeyChar 'Label5.Text = Asc(e.KeyChar) Select Case Asc(e.KeyChar) Case 8, 48 To 57 Case 13 SendKeys.Send("{tab}") Case Else e.Handled = True End Select End Sub End Class |