Results 1 to 4 of 4

Thread: data entry into textbox

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Posts
    20

    data entry into textbox

    hi,
    how do i allow only numbers or null allowed to be entered into a textbox?

  2. #2
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: data entry into textbox

    Search the forum. You will find loads of responses to this question.
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  3. #3
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Lancashire UK
    Posts
    375

    Re: data entry into textbox

    This will only allow numbers to be entered.

    VB Code:
    1. Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
    2.         If Not Char.IsNumber(e.KeyChar) Then
    3.             e.Handled = True
    4.         End If
    5.     End Sub
    If my post helps , please feel free to rate it

  4. #4
    Addicted Member
    Join Date
    Mar 2006
    Posts
    235

    Re: data entry into textbox

    You should also allow the backspace key to be pressed.

    VB Code:
    1. If Char.IsNumber(e.KeyChar) = False And Asc(e.KeyChar) <> 8 Then
    2.       e.Handled = True
    3.     End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width