Hi TopGiver
I have another problem which is related to the above but is down to my lack of clear understanding of boolean logic and whether to use an if....else statement, a case statement or a combination of them both. The conditional statement below fails and I am getting muddled with the boolean construct..can you point me in the right direction?
As discussed before, I wish to validate a textbox (txtF2Total) to accept just 3 possible values: "0", "2" and "9". I then want to validate a number of other textboxes on the same form to meet certain conditions dependent on the value displayed in txtF2Total. e.g.
if txtF2Total = '0' then all other textbxes values MUST be'0','2','3'or'9'
if txtF2Total = '2' then all other textbxes values MUST be '0','2' or '9'
if txtF2Total = '9' then all other textbxes values MUST be '0' or '9'
Here's the context so far:
Private Sub txtCentre_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtCentre.Validating, txtInnerInferiorHELevel.Validating, txtInnerNasalHELevel.Validating, txtInnerNasalHELevel.Validating, txtInnerSuperiorHELevel.Validating, txtInnerTemporalHELevel.Validating, txtOuterInferiorHELevel.Validating, txtOuterNasalHELevel.Validating, txtOuterSuperiorHELevel.Validating, txtOuterTemporalHELevel.Validating
Dim myControl As Control
myControl = CType(sender, Control)
If (txtF2Total.Text = "0") Then
If Not(myControl.Text = "0" Or myControl.Text = "2" Or myControl.Text = "3" Or myControl.Text = "9") Then
ErrorProvider1.SetError(myControl, "is not 0, 2, 3 or 9 !")
myControl.Focus()
myControl.Refresh()
myControl.ResetText()
Else
ErrorProvider1.SetError(myControl, Nothing)
End If
If (txtF2Total.Text = "2") Then
If Not (myControl.Text = "0" Or myControl.Text = "2" Or myControl.Text = "9") Then
ErrorProvider1.SetError(myControl, "is not 0, 2 or 9 !")
myControl.Focus()
myControl.Refresh()
myControl.ResetText()
Else
ErrorProvider1.SetError(txtF2Total, Nothing)
End If
If (txtF2Total.Text = "9") Then
If Not (myControl.Text = "0" Or myControl.Text = "9") Then
ErrorProvider1.SetError(myControl, "is not 0 or 9 !")
myControl.Focus()
myControl.Refresh()
myControl.ResetText()
Else
ErrorProvider1.SetError(txtF2Total, Nothing)
End If
Else
ErrorProvider1.SetError(myControl, Nothing)
End If
Else
ErrorProvider1.SetError(myControl, Nothing)
End If
'Problems with this statement????????