Start New Discussion within our Software Development Community

I'm having trouble with the AND operator when I used it 3 times.

If Text1.Text = "THIS" And Text2.Text = "THAT" and Text3.Text = "THOSE" then
    Call Display

elseIf Text1.Text = "THIS" And Text2.Text = "THAT" and Text3.Text = "THOSE" then
    Call Display2   

else
    MsgBox"Failed"
End If

It always ends up to the ELSE statement even if all the expressions are TRUE.
When I try to remove the 3rd expression (and Text3.Text = "THOSE"), it works.

Any way to round this? I tried using Goto, Select Case and nested If but does't work also.

The code works fine

Private Sub Command1_Click()
If Text1.Text = "This" And Text2.Text = "That" And Text3.Text = "Those" Then
MsgBox ("1")
ElseIf Text1.Text = "This" And Text2.Text = "That" And Text3.Text = "Those" Then
MsgBox ("2")
Else
MsgBox ("Failed")
End If
End Sub

Private Sub Form_Load()
Text1.Text = "This"
Text2.Text = "That"
Text3.Text = "Those"
End Sub

don't forget the brackets around the msg. Also you will never enter the elseif if thats exactly the same as in the if statement

This question has already been answered. Start a new discussion instead.