Results 1 to 6 of 6

Thread: How to only allow numbers to be typed in a textbox?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    How to only allow numbers to be typed in a textbox?

    How could i only allow the user to type in numbers? (. allowed because of decimal points) and only 1 decimal point?
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: How to only allow numbers to be typed in a textbox?

    You can try this control of MartinLiss.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: How to only allow numbers to be typed in a textbox?

    Search the forum for "only number textbox" or "numerical textbox" etc. But there are many complications to making this working properly, without cursor jumping around, then to think about pasting using keyboard, pasting using the right-click popup menu etc.

  4. #4
    PowerPoster
    Join Date
    Jul 2010
    Location
    NYC
    Posts
    7,667

    Re: How to only allow numbers to be typed in a textbox?

    With modern computers, unless you're in a situation where fractions of seconds are important, just go through each character, Mid(.text,var,1), on the change event... it fires for keypresses, paste, and even WM_SETTEXT (which makes it useful for rudimentary interprocess communication).

  5. #5
    Lively Member
    Join Date
    Jan 2009
    Posts
    93

    Re: How to only allow numbers to be typed in a textbox?

    You could also try to use the Masked Edit Control text box by adding the Microsoft Masked Edit Control component to your project. The mask of ####.# will allow numbers in the thousands and only one decimal.

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: How to only allow numbers to be typed in a textbox?

    Hmm... Okay. THanks all for examples. =D
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

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