Re: Help with IF statement
If Label3(SP + 3).Caption = "2.2" And Label3(SP + 1).Caption = "####82-#" Then
Re: Help with IF statement
If Label3(SP + 3).Caption = "2.2" And Mid$(Label3(SP + 1).Caption,5 2) = "82" Then
Re: Help with IF statement
Thank you for the quick response. It worked greatly. If I wanted to add another If in there, like
Code:
If Label3(SP + 3).Caption = "2.16" And Mid$(Label3(SP + 1).Caption, 5, 2) = "72" Then
MsgBox ("Diameter and Carbon Passed!")
Else
MsgBox ("STOP! INCORRECT CARBON AND DIAMETER MATCH! CONTACT SUPERVISOR NOW!")
End
End If
Where it also looks for 2.16 and ="72", on top of the 2.20 and = "82", how would you code that?
Would it look something like
Code:
If Label3(SP + 3).Caption = "2.20" And Mid$(Label3(SP + 1).Caption, 5, 2) = "82" OR If Label3(SP + 3).Caption = "2.16" And Mid$(Label3(SP + 1).Caption, 5, 2) = "72" Then
MsgBox ("Diameter and Carbon Passed!")
Else
MsgBox ("STOP! INCORRECT CARBON AND DIAMETER MATCH! CONTACT SUPERVISOR NOW!")
End
End If
?
Re: Help with IF statement
Quote:
Originally Posted by
MartinLiss
If Label3(SP + 3).Caption = "2.2" And Mid$(Label3(SP + 1).Caption,5 2) = "82" Then
If the length & format of (SP+1) can vary, then maybe this:
Code:
If Label3(SP + 3).Caption = "2.2" And InStr(Label3(SP + 1).Caption, "82-") Then
Re: Help with IF statement
Zach
It probably should look like this -- ie, use parentheses, and eliminate
the 2nd 'If'
Code:
If (Label3(SP + 3).Caption = "2.20" And Mid$(Label3(SP + 1).Caption, 5, 2) = "82") _
Or (Label3(SP + 3).Caption = "2.16" And Mid$(Label3(SP + 1).Caption, 5, 2) = "72") Then
MsgBox ("Diameter and Carbon Passed!")
Else
MsgBox ("STOP! INCORRECT CARBON AND DIAMETER MATCH! CONTACT SUPERVISOR NOW!")
End
End If
Spoo
Re: Help with IF statement
BTW you should not use 'End'. Use Unload Me instead.