KeyPress

L

Lou

How can I limit the input to just digits 0-9

in VB6 I would use the
if KeyAscii<48 or Keyascii >57 then Keyascii=0

-Lou
 
C

Chris

Lou said:
How can I limit the input to just digits 0-9

in VB6 I would use the
if KeyAscii<48 or Keyascii >57 then Keyascii=0

-Lou

I assume you mean in the keypress event...

if asc(e.keychar) < keys.0 or asc(e.keychar) > Keys.9 then
e.handled = true
end if

I'm not positive but I think you also need...
if asc(e.keychar) < keys.D0 or asc(e.keychar) > keys.D9 then
e.handled = true
end if

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top