1 Dim Str As String = "" 2 Private Sub txtRecond_KeyUp(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles txtRecond.KeyUp 3 txtRecond.Text = Regex.Replace(txtRecond.Text, "[^0-9]", "") 4 If txtRecond.Text = "" Then 5 Return 6 End If 7 Try 8 Dim num As Integer = Integer.Parse(txtRecond.Text) 9 txtRecond.Text = num.ToString()10 If (num > 100) Or (num = 0) Then11 txtRecond.Text = ""12 End If13 Catch ex As Exception14 txtRecond.Text = ""15 End Try16 17 18 End Sub19 20 Private Sub txtRecond_KeyPress(sender As System.Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtRecond.KeyPress21 If Char.IsDigit(e.KeyChar) Or e.KeyChar = Chr(8) Or e.KeyChar = "." Then22 If e.KeyChar = "." And InStr(txtRecond.Text, ".") > 0 Then23 e.Handled = True24 Else25 e.Handled = False26 End If27 Else28 e.Handled = True29 End If30 31 End Sub