Three things...
1. In order to permit floating point values to be typed in, your code must allow the user to type in a decimal point character. If that is all the user types in, then the TextBox will not contain a number, rather, it will contain just a single non-digit character... the decimal point character. So, any code that makes use of the value in the TextBox will have to test for it containing just a single decimal point character before attempting to use it as if it were a numeric value.
2. Your code, as written, will not prevent the user from copy/pasting non-digits, non-decimal points into the TextBox, so one cannot count on the contents of the TextBox being a guaranteed numeric value (once a single decimal point character has been ruled out).
3. I assume you missed this posting of my in response to another message in this forum... http://www.excelfox.com/forum/f2/sub...-306/#post1039. The second code box contains routine that restricts the entry to a TextBox to a floating point number and overcomes the problem outlined in #2 above; however, it suffers from the same problem as your code does as outlined in #1 above. As written, the indicated code does not pop up the MessageBox the way your code does, but that is easily fixed by replacing the Beep command with your MessageBox line.




Reply With Quote

Bookmarks