Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
260
UltraMaskedEdit - Remove leading zeros on integer on field leave
posted

I have an application that uses the UltraMaskedEdit control for integers and decimals. When a user types in "000", "0", or ""; the value of the control is zero, however the text of the control remains as the user typed.

I am using input masks "nnnn" and "nnn,nnn.nn". I would like, on field leave, for these to be displayed as "0" and "0.00" respectively if the user typed in something that equates to zero. If the user types in "004", I would like it to display "4" and "4.00" respectively.


My current working solution is to set the value of the control to the text of the control on leave, however I would greatly prefer to use integrated functionality instead. Attached is a VS2010 project that can be used to duplicate this behavior.

The code in the field leave event that is my current solution:


            If IsDBNull(Me.Value) Then
                Me.Text = 0
            Else
                Me.Text = Me.Value
            End If

Input Mask.rar