If you want to avoid using the MaskEdit control tnen you can use a regular TextBox and restric the user to have only 2 (or whatever number) of decimal points there. Put this code on KeyPress event of that TextBox:
This will allow only Numbers, Decimal Point and Backspace.Code:Private Sub Text1_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case 8 Case 46 If InStr(Text1.Text, ".") Then KeyAscii = 0 Case Else If Not IsNumeric(Chr(KeyAscii)) Then KeyAscii = 0 If InStr(Text1.Text, ".") Then If Len(Mid(Text1.Text, InStr(Text1.Text, ".") + 1)) = 2 Then KeyAscii = 0 End If End If End Select End Sub




Reply With Quote