|
-
Oct 22nd, 2003, 11:11 AM
#1
Thread Starter
Lively Member
**RESOLVED** OR Statement Skips Sixth Line?
I ran into this scenerio:
If s = 1 OR _
s = 2 OR _
s = 3 OR _
s = 4 OR _
s = 5 OR _
s = 6 OR _
s = 7 Then
VB6 SP5 seems to skip the s = 6 statement. If you move value around like so:
If s = 1 OR _
s = 2 OR _
s = 3 OR _
s = 4 OR _
s = 6 OR _
s = 5 OR _
s = 7 Then
It skips the 5. VB does not look at the 6th OR Position!!
Is there a better way to write a statement than all the OR's.
Thanks
Last edited by sthomas; Oct 22nd, 2003 at 12:10 PM.
-
Oct 22nd, 2003, 11:17 AM
#2
PowerPoster
if S is an integer, you could do
if S >= 1 AND S <= 7 then
-
Oct 22nd, 2003, 11:33 AM
#3
Re: OR Statement Skips Sixth Line?
Originally posted by sthomas
I ran into this scenerio:
If s = 1 OR _
s = 2 OR _
s = 3 OR _
s = 4 OR _
s = 5 OR _
s = 6 OR _
s = 7 Then
VB6 SP5 seems to skip the s = 6 statement. If you move value around like so:
If s = 1 OR _
s = 2 OR _
s = 3 OR _
s = 4 OR _
s = 6 OR _
s = 5 OR _
s = 7 Then
It skips the 5. VB does not look at the 6th OR Position!!...
I strongly doubt that that what's happening. Can you post your actual code?
-
Oct 22nd, 2003, 11:41 AM
#4
Thread Starter
Lively Member
Yes, but the example I gave you was just an example. What I Really have are sporatic numbers mixed in between other numbers so I can't do what you suggest:
Example:
If s = 10 OR _
s = 15 OR_
s = 2000 Then
-
Oct 22nd, 2003, 11:43 AM
#5
I still say there's something else going on but unless you are willing to show actual code I guess I can't help.
-
Oct 22nd, 2003, 11:53 AM
#6
Thread Starter
Lively Member
Sorry MartinI had to recreate the code: PS it seems to be the 7th OR statement:
Private Sub Command1_Click()
Dim s(100) As String
Dim i As Integer
For i = 1 To 50
s(i) = "1752"
Next i
s(36) = "1619"
If s(36) = "1001" Or _
s(36) = "1002" Or _
s(36) = "1014" Or _
s(36) = "1573" Or _
s(36) = "1700" Or _
s(36) = "1752" Or _
s(36) = "l619" Or _
s(36) = "1754" Or _
s(36) = "1755" Then
MsgBox s(36)
Else
MsgBox "Skipped 1619"
End If
End Sub
-
Oct 22nd, 2003, 11:55 AM
#7
Thread Starter
Lively Member
Sorry for the sloppy code but I tried to hurry and get it posted. On my system it does skip!!
-
Oct 22nd, 2003, 11:56 AM
#8
s(36) = "l619" Or _
Is it really that way in your code? It should be
s(36) = "1619" Or _
-
Oct 22nd, 2003, 11:57 AM
#9
Thread Starter
Lively Member
hold on, I see I have l619 in my example. Let me check my actual code and see if I did the same dumb thing...
-
Oct 22nd, 2003, 12:04 PM
#10
Thread Starter
Lively Member
Thank you Martin. When I copied my code to this forum the font used made it very clear that it was an L instead of a 1. In VB a 1 and an L look so close I couldn't tell.
I guess what I am trying to do is make myself look not as dumb as you may think.
Thanks
-
Oct 22nd, 2003, 12:08 PM
#11
I'm sure I've done the same thing. One thing to learn from this is that not many people actually find a real bug in VB, so when something appears to be a bug check the code really thoroughly because it's usually programmer error.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|