Excel VBA - textbox form - Issue when pressing the point key in the keyboard's numberpad

jorgito111

New Member
Joined
Jun 2, 2018
Messages
2
Hi all,

I'm using Excel 2007.

I've created a form that contains a textbox for which a numerical input is expected.

My excel settings use the "," as decimal separator by default (this means that when I enter a value in an worksheet cell and I press the "." key in my keyboard's numberpad, a "," appears as decimal separator)

But when I to input a number in the textbox of my form and I press the "." key in my keyboard's numberpad, a "." appears instead of a ",".

This generates a problem because when I use the IsNumeric function to validate the information entered in the textbox, although it accepts it as a number, if the number has a "." instead of a "," as a decimal separator, it recognizes it as a different number than the one I originally intended to input. Example:

1.1 --> shows 11
1.11 --> shows 1.11 but considers it as a number bigger than 100

I'd appreciate your help on how to get a decimal separator in the textbox that matches the excel settings when press the "." key in my keyboard's numberpad. (so that any user, with any personal setting for the decimal separator, can use the form and enter numbers using its keyboard's numberpad)

Thank you!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Re: Excel VBA - textbox form - Issue when pressing the point key in the ketboard's numberpad

Hi again, I found a solution. Although when pressing the "." key in my keyboard's numberpad will always give a point, I created a sub that detects the system decimal separator and changes the input symbol ("," or ".") to match the system's decimal separator: Private Sub txtTextBox_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) If Application.International(xlDecimalSeparator) = "," Then If KeyAscii = 46 Then KeyAscii = 44 End If Else If KeyAscii = 44 Then KeyAscii = 46 End If End If End Sub
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,257
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top