Ran into the first issue with it since I started using it in the actual app, here's the updated code:Code:Option Explicit On Option Strict On Option Infer Off <DebuggerStepThrough()> _ Public Class InchNUD Inherits System.Windows.Forms.NumericUpDown Private Const _DQuotes As String = """" Public Overrides Property Text() As String Get Return MyBase.Text End Get Set(ByVal Value As String) Dim TempValue As Decimal = Decimal.Parse(Value.Replace(_DQuotes, String.Empty)) Select Case True Case TempValue > Me.Maximum : MyBase.Value = Me.Maximum Case TempValue < Me.Minimum : MyBase.Value = Me.Minimum Case Else : MyBase.Value = TempValue End Select MyBase.Text = MyBase.Value.ToString & _DQuotes End Set End Property Protected Overrides Sub OnKeyPress(ByVal e As System.Windows.Forms.KeyPressEventArgs) MyBase.OnKeyPress(e) If e.KeyChar = _DQuotes Then Me.Text &= e.KeyChar End Sub Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs) MyBase.OnTextChanged(e) Dim tmp As Decimal If Decimal.TryParse(Me.Text.Replace(_DQuotes, String.Empty), tmp) Then If Me.Value <> tmp Then Me.Value = tmp End If End Sub End Class




Reply With Quote