masked input 
Author Message
 masked input

is there an easy way of masking keyboard input to a text
box?
eg restricting entry to numerics etc
(0-9, .)

thanks



Sun, 27 Nov 2005 19:10:36 GMT  
 masked input
Hi,

        Check to see if it is a number in the keypress event.  Set e.Handled
to true if you dont want the key to show up.

Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

If Asc(e.KeyChar) = Keys.Back Or Asc(e.KeyChar) = Keys.Delete Then

e.Handled = False

Else

e.Handled = Not IsNumeric(e.KeyChar)

End If

End Sub

Ken

-------------------


Quote:
> is there an easy way of masking keyboard input to a text
> box?
> eg restricting entry to numerics etc
> (0-9, .)

> thanks



Sun, 27 Nov 2005 19:32:16 GMT  
 masked input
Hello,


Quote:
> is there an easy way of masking keyboard input to a text
> box?
> eg restricting entry to numerics etc
> (0-9, .)

You may want to use the NumericUpDown control instead of the textbox.

Regards,
Herfried K. Wagner
--
http://www.mvps.org/dotnet



Sun, 27 Nov 2005 19:44:40 GMT  
 masked input
thanks ken :)
Quote:
>-----Original Message-----
>Hi,

>        Check to see if it is a number in the keypress

event.  Set e.Handled
Quote:
>to true if you dont want the key to show up.

>Private Sub TextBox1_KeyPress(ByVal sender As Object,
ByVal e As
>System.Windows.Forms.KeyPressEventArgs) Handles
TextBox1.KeyPress

>If Asc(e.KeyChar) = Keys.Back Or Asc(e.KeyChar) =
Keys.Delete Then

>e.Handled = False

>Else

>e.Handled = Not IsNumeric(e.KeyChar)

>End If

>End Sub

>Ken

>-------------------



>> is there an easy way of masking keyboard input to a text
>> box?
>> eg restricting entry to numerics etc
>> (0-9, .)

>> thanks

>.



Sun, 27 Nov 2005 19:52:45 GMT  
 masked input

    Private Sub txtPhoneAreaNumber_KeyPress(ByVal sender
As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles
txtPhoneAreaNumber.KeyPress
        If Char.ToUpper(e.KeyChar) < "0"c Or Char.ToUpper
(e.KeyChar) > "9"c Then
            If Char.ToUpper(e.KeyChar) <> Chr(8).ToString
And Char.ToUpper(e.KeyChar) <> Chr(13).ToString Then
                e.Handled = True
            End If
        End If
    End Sub

Smiles
Ahsan

Quote:
>-----Original Message-----
>is there an easy way of masking keyboard input to a text
>box?
>eg restricting entry to numerics etc
>(0-9, .)

>thanks
>.



Sun, 27 Nov 2005 20:26:11 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Mask input to a textbox

2. Dates in a masked input control

3. Masked input - shareware vbx ?

4. Masked input box won't see CR

5. Datagrid Masked Input ?????

6. Mask input of a database.

7. Mask input of a database.

8. Input Mask error

9. Add input mask to INPUTBOX function

10. Email Input Mask

11. Question - Input Masks on Forms and Tables

12. Masking a Input Box

 

 
Powered by phpBB® Forum Software