Public Class clsPoleLiczbowe
    Inherits TextBox
    Private m_strOstatniaWartość As String
    Private m_ttDymek As New ToolTip

    Public Sub New()
        With m_ttDymek
            .IsBalloon = True
            .ToolTipIcon = ToolTipIcon.Info
            .ToolTipTitle = "Wymagane dane liczbowe"
            .InitialDelay = 0
            .ReshowDelay = 0
            .SetToolTip(Me, "Wpisz liczbę.")
        End With

    End Sub

    Private Sub clsPoleLiczbowe_KeyPress(sender As Object, e As KeyPressEventArgs) Handles Me.KeyPress
        If Not (IsNumeric(e.KeyChar)) Then
            Select Case AscW(e.KeyChar)
                Case Keys.Enter, Keys.Back, Keys.Tab, Asc("$"), Asc("."), Asc(",")
                Case Else
                    e.Handled = True
            End Select
        End If

    End Sub

    Private Sub clsPoleLiczbowe_TextChanged(sender As Object, e As EventArgs) Handles Me.TextChanged
        If Not (IsNumeric(Me.Text)) And Me.Text.Length > 0 Then
            ' Wklejona wartość nie jest liczbą.
            MyBase.Text = m_strOstatniaWartość
        Else
            m_strOstatniaWartość = MyBase.Text
        End If

    End Sub
End Class
