mask property negative numbers

How do I allow negative numbers to be entered into the TextField using the mask property. I have tried “99.9999” and “##.####”, but can not enter negative numbers only positive numbers.

me.Mask = “&####.##”

permits the initial entry of the “-”

[quote=386348:@Roger Clary]me.Mask = “&####.##”

permits the initial entry of the “-”[/quote]

It also permits the entry of A657 or K78, so it’s not suitable.

In short, forget about the mask. Go to Great White Software http://www.great-white-software.com/Xojo_Code.html for Norman’s Masked Edit Field. Works out of the box on TextFields, too.

Or make your own by using the KeyDown event with code similar to this:

if IsNumeric( Key ) then // Allow numeric return false elseif ( Key = "." ) and ( InStr( me.Text, "." ) = 0 ) and me.Text.Len > 0 then // Handle decimal points return false elseif ASC( Key ) < 32 then // Allow control keys (e.g. the backspace key) return false else // Ignore all other input return true end if

Why would one write all of that code when a single line will serve the OP’s purpose.

Read the first line of my response again.

And he doesn‘t have to write anything, you can copy&paste on computers … :wink: