943,632 Members | Top Members by Rank

Ad:
Mar 22nd, 2005
0

New to VB can someone help ?

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Alfarata is offline Offline
10 posts
since Feb 2005
Mar 22nd, 2005
0

Re: New to VB can someone help ?

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:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. if text1.text = "hi" or "bye" then ' <-- improper testing condition

However,

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. if text1.text = "hi" or text1.text = "bye" then '<-- proper testing condition
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Mar 25th, 2005
0

Re: New to VB can someone help ?

Quote originally posted by Alfarata ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
N[e]tt[e] is offline Offline
18 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Listbox's Remove item
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Data App With Multiple Windows





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC