+ 1

How can i disable space in visual basic and how i can only put one hypen

I already have my codes but its not complete yet here it is If txtstudentnumber.text.contains("-") then If Char.IsDigit(e.KeyChar) or e.KeyChar = Chr (8) then e.Handled = True Else e.Handled = False End If End If

8th Nov 2018, 11:15 AM
Ahmil Orijola
Ahmil Orijola - avatar
6 odpowiedzi
0
I don't have a computer at home to check the code it could be like this. If Not Char. IsDigit(e. KeyChar) OrElse Not Char. Is Control(e. KeyChar) OrElse Not( e. KeyChar =chrW(8)) Then e. Handled = True End If
8th Nov 2018, 1:57 PM
Asgar Ali
Asgar Ali - avatar
0
What are you trying to do?
8th Nov 2018, 12:10 PM
Asgar Ali
Asgar Ali - avatar
0
im trying to make my textbox input only numbers and only 1 hypen
8th Nov 2018, 12:27 PM
Ahmil Orijola
Ahmil Orijola - avatar
0
If Not Char. IsDigit(e. KeyChar) OrElse Not Char. Is Control(e. KeyChar) Then e. Handled = True End If This is to input only numbers in text box. Where you want to put your hifen?
8th Nov 2018, 12:41 PM
Asgar Ali
Asgar Ali - avatar
0
numbers with only one hypen like for example a school id number 12-3271 like that
8th Nov 2018, 12:42 PM
Ahmil Orijola
Ahmil Orijola - avatar
0
thanks
9th Nov 2018, 12:49 AM
Ahmil Orijola
Ahmil Orijola - avatar