TexBox with only Numbers

I wil have a textbox with the only option to input numbers and a . or , , How to do?

Subclass a textfield and add a method like the one below. Then, in the keydown event handler, you can call this method and return true or false:

[code]Function isDigit(key As String) As Boolean

if (asc(key)>=48 AND asc(key)<=59) _ // keys 0 to 9
OR (asc(key)=8 _ // Backspace
OR asc(key)=127 _ // Delete
OR asc(key)=9 _ // Tab
OR asc(key)=28 _ // Left
OR asc(key)=45 _ // -
OR asc(key)=43 _ // +
OR asc(key)=decPointAscVal _ // . or , see constructor
OR asc(key)=29) then // Right

Return True

else
Return False
end if
End Function
[/code]

Still allows entries like 9-++32.4–+