Results 1 to 11 of 11

Thread: **RESOLVED** OR Statement Skips Sixth Line?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Posts
    95

    **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.

  2. #2
    PowerPoster
    Join Date
    Aug 2001
    Location
    new jersey
    Posts
    2,904
    if S is an integer, you could do

    if S >= 1 AND S <= 7 then

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    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?

  4. #4

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Posts
    95
    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

  5. #5

  6. #6

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Posts
    95
    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

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Posts
    95
    Sorry for the sloppy code but I tried to hurry and get it posted. On my system it does skip!!

  8. #8

  9. #9

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Posts
    95
    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...

  10. #10

    Thread Starter
    Lively Member
    Join Date
    May 2001
    Posts
    95
    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

  11. #11
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    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
  •  



Click Here to Expand Forum to Full Width