Estoy intentando que el textbox sólamente acepte números, y una coma (sólamente una coma),
No se que estoy haciendo mal (Acepta más de una coma).
Private Sub TextBox_Custom_Size_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox_Custom_Size.KeyPress
e.Handled = NumericOnly(e.KeyChar)
End Sub
Public Function NumericOnly(ByVal eChar As Char) As Boolean
Dim chkStr As String = "0123456789,"
If chkStr.IndexOf(eChar) > -1 OrElse eChar = vbBack Then
If eChar = Keys.Oemcomma & TextBox_Custom_Size.Text.Contains(",") Then Return True
Return False
Else
Return True
End If
End Function
Saludos!
Creo que así funcionaria.
Private Sub TextBox_Custom_Size_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox_Custom_Size.KeyPress
e.Handled = NumericOnly(e.KeyChar)
End Sub
Public Function NumericOnly(ByVal eChar As Char) As Boolean
Dim chkStr As String = "0123456789,"
If chkStr.IndexOf(eChar) > -1 OrElse eChar = vbBack Then
If eChar = Chr(44) And TextBox1.Text.Contains(",") Then Return True
Return False
Else
Return True
End If
End Function
saludos
Cita de: EleKtro H@cker en 15 Enero 2013, 16:39 PM
Gracias, pero no :(
seguro ?
a mi me funciona:S
cambiaste el nombre a tu textbox correspondiente?
If eChar = Chr(44) And TextBox_Custom_Size.Text.Contains(",") Then Return True
Ups, acabo de copiar tu code tál cual y si que funciona, algo habré puesto mal en mi code xD
Solucionado, gracias de nuevo.