Results 1 to 7 of 7

Thread: Textbox with Decimal comma

  1. #1

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Textbox with Decimal comma

    Hi

    I need to configure a textbox, that accept only number and with decimal comma , How can I to do it ?

    tks

  2. #2
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: Textbox with Decimal comma

    Use IsNumeric(String).

  3. #3
    PowerPoster gavio's Avatar
    Join Date
    Feb 2006
    Location
    GMT+1
    Posts
    4,462

    Re: Textbox with Decimal comma

    VB Code:
    1. Private Sub Text1_KeyPress(KeyAscii As Integer)
    2.     Select Case (Chr(KeyAscii))
    3.         Case "0" To "9":
    4.             Exit Sub
    5.         Case ".":
    6.             Exit Sub
    7.         Case Else:
    8.             KeyAscii = 0
    9.     End Select
    10. End Sub

  4. #4
    Hyperactive Member
    Join Date
    Apr 2004
    Posts
    342

    Re: Textbox with Decimal comma

    You can check for it yourself in _KeyPress Event or Look at the "Microsoft Masked Edit Control".

  5. #5

    Thread Starter
    Fanatic Member mutley's Avatar
    Join Date
    Apr 2000
    Location
    Sao Paulo - Brazil
    Posts
    709

    Re: Textbox with Decimal comma

    I do not like to use Maskedit

  6. #6

  7. #7
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Textbox with Decimal comma

    Be careful with decimals, specially because the computer will use the one selected in regional settings, it could be comma or dot, depending on each computer. The best way to be safe is bringing it as it is in Regional settings:
    VB Code:
    1. DecimalSeparator = Format$(0, ".")
    Also, be careful with conversions, Val() doesnt work when the decimal separator is comma, you have to use CDbl().

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