New to VB can someone help ?

Reply

Join Date: Feb 2005
Posts: 10
Reputation: Alfarata is an unknown quantity at this point 
Solved Threads: 0
Alfarata Alfarata is offline Offline
Newbie Poster

New to VB can someone help ?

 
0
  #1
Mar 22nd, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: New to VB can someone help ?

 
0
  #2
Mar 22nd, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 18
Reputation: N[e]tt[e] is an unknown quantity at this point 
Solved Threads: 0
N[e]tt[e] N[e]tt[e] is offline Offline
Newbie Poster

Re: New to VB can someone help ?

 
0
  #3
Mar 25th, 2005
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC