
VB4 newbie help: Reading a real into a textbox
Quote:
>I want to do something simple like restrict a users input into
>a textbox, making sure that it is a real (or integer). I
>know that you can use the keypress event to limit the allowable
>keystrokes to numbers and the decimal, but I can't stop the
>user from entering 3.14.159.
You could test if the text already contains a "." in the keyPress event:
Sub Text1_KeyPress(keyAscii as integer)
If keyAscii= Asc(".") then
if instr(text1,".") then
beep
keyAscii=0
endif
endif
end sub
You should also limit entering "-" to at the front of the text, using
Text1.SelStart.
Be careful about using CSng(Text) + error catching, since this won't
allow you to enter a sibngle "-".
Gent (Ghent, Gand),
Belgium,
Europe,
3rd planet from the sun.