I have a userform setup such than the user can enter a part number. I am trying to do a check to make sure that a part number is valid. If it is not valid then I want to go to a sub routine where I put a msgbox stating it is an invalid number and then exit the sub. HEre is some of the code that I am running.
Unfortuantely no matter what I do the invalid_pn_code routine always runs. What am I doing wrong?
Code:
opt(1) = Mid(ipn, 5, 1)
If opt(1) <> 1 Or opt(1) <> 2 Or opt(1) <> 3 Or opt(1) <> 4 Then
inv_opt = 1
inv_val = opt(1)
GoTo Invalid_PN_code
End If
opt(2) = Mid(ipn, 6, 1)
If opt(2) <> 0 Or opt(2) <> 1 Or opt(2) <> 2 Then
inv_opt = 2
inv_val = opt(2)
GoTo Invalid_PN_code
End If
opt(3) = Mid(ipn, 7, 1)
If opt(3) <> 0 Or opt(3) <> 1 Or opt(3) <> 2 Then
inv_opt = 3
inv_val = opt(3)
GoTo Invalid_PN_code
End If
opt(4) = Mid(ipn, 8, 1)
If opt(4) <> 0 Or opt(4) <> 1 Or opt(4) <> 2 Then
inv_opt = 4
inv_val = opt(4)
GoTo Invalid_PN_code
End If
'more code here
' \/
' \/
' \/
'ends with this code
Invalid_PN_code:
MsgBox "Invalid " + Prod + " Part Number" + Chr(10) + "A " + inv_val + " for Option " + inv_opt + " is not a valid option."
Exit Sub
End Sub
Unfortuantely no matter what I do the invalid_pn_code routine always runs. What am I doing wrong?