Results 1 to 2 of 2

Thread: Allow Percentage Only at textbox

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2003
    Posts
    6

    Exclamation Allow Percentage Only at textbox

    Does anyone knows how to code to format the textbox to accept only percentage. (3 digits, 1 decimal point, 2 digits) ? i also want to be able to set the limit to 100.00.

  2. #2
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    heres some code to only accept numbers and a decimal point...hope this help.


    VB Code:
    1. Dim KeyAscii As Integer
    2.         KeyAscii = Asc(e.KeyChar)
    3.         'only allow numbers, a single decimal point, backspace  or enter        
    4.         Select Case KeyAscii
    5.             Case Asc("0") To Asc("9"), Asc(ControlChars.Back), Asc("-")
    6.                 'acceptable(keystrokes)
    7.                 e.Handled = False
    8.             Case Asc(".")
    9.                 e.Handled = False
    10.             Case Else
    11.                 e.Handled = True
    12.         End Select
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

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