You are on page 1of 2

q

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click
If (TextBox2.Text <> "") And (TextBox3.Text <> "") Then

TextBox4.Text = Val(TextBox2.Text * TextBox3.Text)


Dim descuento As Double = Val(TextBox4.Text * 0.2)
TextBox5.Text = Val(TextBox4.Text - descuento)
Else
MsgBox("Todos los campos obligatorios estan vacios")
End If
End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles


Button2.Click
TextBox1.Text = Nothing
TextBox2.Text = Nothing
TextBox3.Text = Nothing
TextBox4.Text = Nothing
TextBox5.Text = Nothing
End Sub

Private Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles


TextBox1.KeyPress
If Char.IsLetter(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsSeparator(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
MsgBox("Este campo no admite caracteres numéricos")

End If
End Sub

Private Sub TextBox2_KeyPress(sender As Object, e As KeyPressEventArgs) Handles


TextBox2.KeyPress
If Char.IsNumber(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsSeparator(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
MsgBox("Este campo no admite caracter alfabeticos")

End If
End Sub

Private Sub TextBox3_KeyPress(sender As Object, e As KeyPressEventArgs) Handles


TextBox3.KeyPress
If Char.IsNumber(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsSeparator(e.KeyChar) Then
e.Handled = False
Else
e.Handled = True
MsgBox("Este campo no admite caracteres alfabeticos")

End If
End Sub

Private Sub TextBox4_KeyPress(sender As Object, e As KeyPressEventArgs) Handles


TextBox4.KeyPress
e.Handled = True
MsgBox("Este campo no acepta entrada de datos")
End Sub

Private Sub TextBox5_KeyPress(sender As Object, e As KeyPressEventArgs) Handles


TextBox5.KeyPress
e.Handled = True
MsgBox("Este campo no acepta entrada de datos")
End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles


Button3.Click
Me.Hide()
Form3.Show()
End Sub

You might also like