\\\
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
///
Ok I posted the code for a better explanation: This code gets called
every keyboard entry.
Public Sub Runtime_Keypress(ByVal sender As Object, ByVal e As
KeyPressEventArgs)
Try
Dim gageValues() As String
gageValues = CStr(CType(sender, Label).Tag).Split(",")
If gageValues(0) = "Keyboard" Then
If e.KeyChar = Chr(8) Then 'This is the backspace
check
If
CType(Me.readingLabelArrayList(sender.tabindex), Label).Text.Length >
0 Then
CType(Me.readingLabelArrayList(sender.tabindex), Label).Text =
CType(Me.readingLabelArrayList(sender.tabindex),
Label).Text.Substring(0,
CType(Me.readingLabelArrayList(sender.tabindex), Label).Text.Length -
1)
End If
ElseIf e.KeyChar = vbCr Then
mNewRuntimeMethods.calcOperations.PerformCalculations(mNewRuntimeMethods.tmpSavedInfo,
readingLabelArrayList, pFile, mNewRuntimeMethods.intCurrentPartNumber,
mNewRuntimeMethods.boolMinMaxStartButtonBeenPressed)
mNewRuntimeMethods.SampleData()
CType(Me.readingLabelArrayList(sender.tabindex),
Label).BorderStyle = BorderStyle.FixedSingle
mNewRuntimeMethods.boolKeyboardSampled = True
Else
If e.KeyChar = Chr(45) Or e.KeyChar = Chr(46) Or
(e.KeyChar >= Chr(48) And e.KeyChar <= Chr(57)) Then
CType(Me.readingLabelArrayList(sender.tabindex), Label).Text +=
e.KeyChar
End If
End If
Else
e.Handled = True
End If
Catch ex As Exception
tListener.AddMethodError(ex)
End Try
End Sub