how i control the key the i am Pressed like number only

I use this code from xojo’s web example. There may be a better way to do it but it works for my needs.

dim i as integer dim result as string for i = 1 to len(me.text) if InStr("0123456789.", me.text.Mid(i, 1)) >0 then result = result + me.text.Mid(i, 1) end if next me.text=result