Visual Basic.NET - Keypress y Change

 
Vista:

Keypress y Change

Publicado por Claudio (1 intervención) el 02/08/2006 03:33:07
En una caja de texto deseo ingresar solo numeros o solo letras
o que solo ingresen mayusculas,
como hacer?
como seria el código?
Un abrazo,

Claudio.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Keypress y Change

Publicado por Harold (411 intervenciones) el 04/08/2006 10:41:58
'Epero te ayude,

'convierte a mayusculas lo que tecleas
Private Sub txtNumeroIdentidad_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtNumeroIdentidad.KeyPress
e.KeyChar = Char.ToUpper(e.KeyChar)
End Sub

'Solo numeros
Private Sub txtTelefono_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtTelefono.KeyPress
If Not Char.IsNumber(e.KeyChar) And Not e.KeyChar = vbBack Then
e.Handled = True
End If
End Sub

'Solo letras
Private Sub txtNombre_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtNombre.KeyPress
If Not Char.Isletter(e.KeyChar) And Not e.KeyChar = vbBack Then
e.Handled = True
End If
End Sub

solo letras y en mayusculas
'Solo letras
Private Sub txtNombre_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtNombre.KeyPress
If Not Char.Isletter(e.KeyChar) And Not e.KeyChar = vbBack Then
e.Handled = True
else
e.KeyChar = Char.ToUpper(e.KeyChar)
End If
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar