Okay what I'm trying to do here is error handling.
Pretty much I have a text box called "TEST" and if I put in a value that is not a number or is not an increment of 0.1 then I get an error with the flashing exclamation mark next to my TEST textbox.
I got everything working fine, I just can't work out the logic for the increments of 0.1! ( Meaning the input can be 0.1, 0.2, 0.3..... 9999.9 but not 4.3321 etc)
I figured:
If (CDec(distance) Mod 0.1 > 0) Then
result = errMsg3
End If
Would work, but it doesnt! Any help on this? Thanks.
Pretty much I have a text box called "TEST" and if I put in a value that is not a number or is not an increment of 0.1 then I get an error with the flashing exclamation mark next to my TEST textbox.
I got everything working fine, I just can't work out the logic for the increments of 0.1! ( Meaning the input can be 0.1, 0.2, 0.3..... 9999.9 but not 4.3321 etc)
I figured:
If (CDec(distance) Mod 0.1 > 0) Then
result = errMsg3
End If
Would work, but it doesnt! Any help on this? Thanks.
VB.NET:
Private Sub TEST_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TEST.Leave
ErrorProvider.SetError(test, controlsCheck(TEST.Text))
End Sub
VB.NET:
Public Function distanceCheck(ByVal distance As String)
Dim result As String
Dim total As Integer
Const errMsg As String = "Field should not be empty"
Const errMsg2 As String = "Field should be more than 0.1"
Const errMsg3 As String = "Field must be in increments of 0.1"
Const errMsg4 As String = "Field must be an integer"
result = ""
If IsNumeric(distance) = False Then
result = errMsg4
Return result
End If
If (distance.Length = 0) Then
result = errMsg
End If
If (CDec(distance) Mod 0.1 > 0) Then
result = errMsg3
End If
If (CDec(distance) < 0.1) Then
result = errMsg2
End If
Return result
End Function
Last edited: