"cmdolcet69" <co************@hotmail.comschrieb:
Is there somthing I can use for a text box control that will help
avoid my users of entering "stupid" data. In many cases our user will
enter number such as 10.0 or 0.50 or even 0,45 however if my user
enter ..045 or ,,045 how can i control this and prompt him to re-
enter.
\\\
Private Sub TextBox1_Validating( _
ByVal sender As Object, _
ByVal e As CancelEventArgs _
) Handles TextBox1.Validating
Dim SourceControl As TextBox = DirectCast(sender, TextBox)
Dim n As Double
If Not Double.TryParse(SourceControl.Text, n) Then
Me.ErrorProvider1.SetError( _
SourceControl, _
"Value must be a double." _
)
Else
If Me.ErrorProvider1.GetError(SourceControl).Length 0 Then
Me.ErrorProvider1.SetError(SourceControl, String.Empty)
End If
...
End If
End Sub
///
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>