"Steven.Xu" <St******@discussions.microsoft.com> schrieb:
It's just a small problem. On previous VB, I can reset the keycode in the
KeyDown or KeyUp event. But in VB.NET, The property of parameter "e" is
readonly. How can I have a TextBox just only could be imputed digital.
\\\
Imports System.ComponentModel.Component
Imports System.Text.RegularExpressions
..
..
..
Private Sub TextBox1_Validating( _
ByVal sender As Object, _
ByVal e As CancelEventArgs _
) Handles TextBox1.Validating
Dim SourceControl As TextBox = DirectCast(sender, TextBox)
Dim ErrorText As String
If Not Regex.IsMatch(SourceControl.Text, "^\d*$") Then
ErrorText = "Value must consist of decimal digits."
End If
Me.ErrorProvider1.SetError( _
SourceControl, _
ErrorText _
)
End Sub
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>