How to identify more than 1 decimal ?

  • Thread starter Thread starter Rob
  • Start date Start date
R

Rob

Using VS 2005

I have an application whereby the user clicks on numbered buttons in order
to "build" a number.... (kind of like the calulator application).

Example... if they click on the 1 button, then the 2 button, then the 3
button, the resulting number will be 123.

There is really no validation required unless a decimal point is involved.

How can I trap (I assume on KeyPress ?) for the user putting in more than 1
decimal point ?
 
I would do it in the KeyPress event.

Use this:

If InStr(textboxnamehere.text,".") then
If e.KeyCode = Keys.Period then
e.Cancel = true
End If
End If
 
Using VS 2005

I have an application whereby the user clicks on numbered buttons in order
to "build" a number.... (kind of like the calulator application).

Example... if they click on the 1 button, then the 2 button, then the 3
button, the resulting number will be 123.

There is really no validation required unless a decimal point is involved.

How can I trap (I assume on KeyPress ?) for the user putting in more than 1
decimal point ?

You say the user is pressing buttons to enter numbers. If the decimal
point is also entered by pressing a button disable that button after
it is pressed once.
 
Rob said:
Using VS 2005

I have an application whereby the user clicks on numbered buttons in order
to "build" a number.... (kind of like the calulator application).

Example... if they click on the 1 button, then the 2 button, then the 3
button, the resulting number will be 123.

There is really no validation required unless a decimal point is involved.

How can I trap (I assume on KeyPress ?) for the user putting in more than
1 decimal point ?

use the textChanged event of the textbox you're building

If textBox1.Text.Contains(".") then
'** do not put another one in there
Else
textBox1.Text &= "."
End If
 
Rob,

If he clicks in more than 1 decimal point, (In English language cultures a
dot, in most others a comma) your Isnumeric gives an error. The most simple
way in my idea.

By the way, try to avoid the KeyPress, the KeyUp gives much more
information.

Cor
 
Back
Top