Results 1 to 7 of 7

Thread: [2008] only numerical values in textbox

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2008
    Posts
    18

    Exclamation [2008] only numerical values in textbox

    Hi all
    in my application there are many textboxes for amount, percentage etc. how can i limit the user to to enter only numerical values in such textboxes.

  2. #2
    Junior Member vks.gautam1's Avatar
    Join Date
    Dec 2008
    Location
    Chandigarh, India
    Posts
    27

    Re: [2008] only numerical values in textbox

    input should store in string variable . Then use TRYparse(vb 2005) fucntion to know input is integer or not. This fucntion will convert value to inetegr. if there is not integer then show message. Try

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] only numerical values in textbox

    This is a very common question. You should search the forum, which you should always do before posting.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: [2008] only numerical values in textbox

    Since you are using VS2008 try using a MaskedTextBox control. It should prevent the user from entering non-numerical characters (or any characters not matching the mask).
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Dec 2008
    Posts
    18

    Exclamation Re: [2008] only numerical values in textbox

    Quote Originally Posted by obi1kenobi
    Since you are using VS2008 try using a MaskedTextBox control. It should prevent the user from entering non-numerical characters (or any characters not matching the mask).

    i can not use masked textbox control because it limits the number of digits

  6. #6
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    Re: [2008] only numerical values in textbox

    Well I don't have a lot of experience with MaskedTextBoxes, so I can't say if that problem can be solved... But I would advise you to consider using NumericUpDown controls since their return type is Decimal (I think).
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  7. #7
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: [2008] only numerical values in textbox

    How about using a NumericUpDown for this? It's not like it was made for this or anything.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

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