Hi
I need to configure a textbox, that accept only number and with decimal comma , How can I to do it ?
tks
Printable View
Hi
I need to configure a textbox, that accept only number and with decimal comma , How can I to do it ?
tks
Use IsNumeric(String).
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer) Select Case (Chr(KeyAscii)) Case "0" To "9": Exit Sub Case ".": Exit Sub Case Else: KeyAscii = 0 End Select End Sub
You can check for it yourself in _KeyPress Event or Look at the "Microsoft Masked Edit Control".
I do not like to use Maskedit
Neither do I. You can make a copy of my NumberBox ocx from the link in my signature.Quote:
Originally Posted by mutley
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:
Also, be careful with conversions, Val() doesnt work when the decimal separator is comma, you have to use CDbl().VB Code:
DecimalSeparator = Format$(0, ".")