| | |
New to VB can someone help ?
![]() |
•
•
Join Date: Feb 2005
Posts: 10
Reputation:
Solved Threads: 0
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
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:
However,
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
if text1.text = "hi" or "bye" then ' <-- improper testing condition
However,
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
if text1.text = "hi" or text1.text = "bye" then '<-- proper testing condition
•
•
Join Date: Feb 2005
Posts: 18
Reputation:
Solved Threads: 0
•
•
•
•
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
![]() |
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Listbox's Remove item
- Next Thread: Data App With Multiple Windows
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






