No matter what I enter in the text box txtDoorSeries when I run with Debug and a watch on DoorCode it always is 1 . It does not fall through the if statements. Am I using the wrong properties?

Thanks for any help.

Sub DrCode()
If Val(txtDoorSeries.Text) = 610 Or 620 Then
DoorCode = 1
ElseIf Val(txtDoorSeries.Text) = 630 Or 631 Or 632 Then
DoorCode = 2
ElseIf Val(txtDoorSeries.Text) = 640 Or 642 Then
DoorCode = 4
ElseIf Val(txtDoorSeries.Text) = 625 Then
DoorCode = 5
ElseIf Val(txtDoorSeries.Text) = 615 Or 616 Then
DoorCode = 9
ElseIf Val(txtDoorSeries.Text) = 650 Or 651 Or 652 Then
DoorCode = 10
Else: MsgBox "Incorrect Door Series Entered", vbCritical + vbOKOnly, "Series Error"
End If
End Sub

because your or comparison is flawed. When you do a comparison, you have to give it multiple conditions, not multiple options of the same condition, so:

if text1.text = "hi" or "bye" then    ' <-- improper testing condition

However,

if text1.text = "hi" or text1.text = "bye" then    '<-- proper testing condition

No matter what I enter in the text box txtDoorSeries when I run with Debug and a watch on DoorCode it always is 1 . It does not fall through the if statements. Am I using the wrong properties?

Thanks for any help.

Sub DrCode()
If Val(txtDoorSeries.Text) = 610 Or 620 Then
DoorCode = 1
ElseIf Val(txtDoorSeries.Text) = 630 Or 631 Or 632 Then
DoorCode = 2
ElseIf Val(txtDoorSeries.Text) = 640 Or 642 Then
DoorCode = 4
ElseIf Val(txtDoorSeries.Text) = 625 Then
DoorCode = 5
ElseIf Val(txtDoorSeries.Text) = 615 Or 616 Then
DoorCode = 9
ElseIf Val(txtDoorSeries.Text) = 650 Or 651 Or 652 Then
DoorCode = 10
Else: MsgBox "Incorrect Door Series Entered", vbCritical + vbOKOnly, "Series Error"
End If
End Sub

em..maybe you should edit ..ur coding is like not right

If Val(txtDoorSeries.Text) = 610 Or Val(txtDoorSeries.Text)=620 Then
DoorCode = 1
ElseIf Val(txtDoorSeries.Text) = 630 Or Val(txtDoorSeries.Text)<= 632 Then
DoorCode = 2
ElseIf Val(txtDoorSeries.Text) = 640 Or Val(txtDoorSeries.Text)=642 Then
DoorCode = 4
ElseIf Val(txtDoorSeries.Text) = 625 Then
DoorCode = 5
ElseIf Val(txtDoorSeries.Text) = 615 Or Val(txtDoorSeries.Text)=616 Then
DoorCode = 9
ElseIf Val(txtDoorSeries.Text) = 650 Or Val(txtDoorSeries.Text)<= 652 Then
DoorCode = 10
Else
MsgBox "Incorrect Door Series Entered", vbCritical + vbOKOnly, "Series Error"
End If

This article has been dead for over six months. Start a new discussion instead.