I am using a textfield for the following calculations.
dim ratio as double
ratio = val(txtmm.text) * 0.0393700787
txtanswer.text = Format(ratio,“0.00000”) + " Inches"
txtcalculation.text = “1 mm = 0.03937 inches”
My question is how do I make the textfield ignor inputs that are not numerical.
Thanks, if I use #### you can input 1234, but no percentage such as 12.34
then if I use ##.## you can enter 12.34 but not 1234
I need to be able to do it both ways, I seem to be not grasping it.
Thanks Dave have have it working fine with the -sign now
If (key<“0” Or key>“9”) and key<>"." and key <>"-" Then Return True
But I am having problems when I try and add a Backspace to it, I have tried the following
If (key<“0” Or key>“9”) and key<>"." and key <>"-" and key=ChrB(8) Then Return True … This is allowing all alpha characters
If (key<“0” Or key>“9”) and key<>"." and key <>"-" and key<>ChrB(8) Then Return True… Back Space doesn’t work with this
If (key<“0” Or key>“9”) and key<>"." and key <>"-" or key<>ChrB(8) Then Return True… This allows no input at all
If (key<“0” Or key>“9”) and key<>"." and key <>"-" or key = ChrB(8) Then Return True…Back Space doesn’t work with this
This just shows my limited knowledge, I thought Dave was just giving me some examples and I had to figure the rest out, Thanks Dave and Tim, I have now used Daves full code and added the bit for the minus and it works fine.