Parells i senars 2.0 (resolta)
Public Class Form1
'CREO VARIABLES
Dim numero, missatge As Integer
'EN PREMER UNA TECLA
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
'SI ESTA FORA DELS MARGES DELS NUMEROS
If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then
'SI ES INTRO O BS
If (Asc(e.KeyChar) = 13) Or (Asc(e.KeyChar) = 8) Then
'SI ES INTRO
If (Asc(e.KeyChar) = 13) Then
'LLEGEIXO NUMERO ENTRAT
numero = Int(TextBox1.Text)
'ESBRINO SI ES PARELL O SENAR
If (numero / 2 = Int(numero / 2)) Then
missatge = MsgBox("El numero " & TextBox1.Text & " es parell", vbOKOnly + vbInformation, "Esbrinador de parells")
Else
missatge = MsgBox("El numero " & TextBox1.Text & " es senar", vbOKOnly + vbInformation, "Esbrinador de parells")
End If
End If
Else
'ANUL.LA ENTRADA
e.Handled = True
End If
End If
End Sub
End Class