Results 1 to 4 of 4

Thread: [RESOLVED] [2005] Odd If statement problem --> code triggered when 'Or' is placed in

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2008
    Posts
    95

    Resolved [RESOLVED] [2005] Odd If statement problem --> code triggered when 'Or' is placed in

    I have this code where i testing weather a picturbox's X value is the same as or similar (within about 3 pixels) as another picturbox's X value. The code is below:
    vb Code:
    1. Private Sub AI_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AI.Tick
    2.         Dim Left, Right, Left2, Right2, Left3, Right3, Left4, Right4 As Integer
    3.         Dim Up, Down, Up2, Down2, Up3, Down3, Up4, Down4
    4.  
    5.         Left = P1CoOrds.X
    6.         Left2 = P1CoOrds.X - 1
    7.         Left3 = P1CoOrds.X - 2
    8.         Left4 = P1CoOrds.X - 3
    9.         Right = P1CoOrds.X
    10.         Right2 = P1CoOrds.X + 1
    11.         Right3 = P1CoOrds.X + 2
    12.         Right4 = P1CoOrds.X + 3
    13.  
    14.         lbl1.Text = Pic1.Location.X
    15.         lbl2.Text = Pic1.Location.Y
    16.         lbl3.Text = AI1.Location.X
    17.         lbl4.Text = AI1.Location.Y
    18.  
    19.         If AI1.Left = Left Or Left2 Or Left3 Or Left4 Then
    20.             CreatePicBox(50, 20, AI1.Location, Color.Blue) 'This is only here to see if the code is being triggered.
    21.         End If
    22.  
    23.     End Sub
    24.  
    25.     Private Sub CreatePicBox(ByVal Height As Integer, ByVal Width As Integer, ByVal Pos As Point, ByVal Colour As Color)
    26.         PicBox = New PictureBox
    27.         PicBox.Height = Height
    28.         PicBox.Width = Width
    29.         PicBox.Location = Pos
    30.         PicBox.BackColor = Colour
    31.         Controls.Add(PicBox)
    32.         PicBoxNo += 1
    33.         lbl5.Text = PicBoxNo
    34.     End Sub

    the first block of code is in a timer running at 1 millisecond. Later on I'll probably reduce that. Anyway, with the "Left or Left2 or Left3 or Left4" it is triggering the code where ever the picturebox is. The x values are completely different and the code is still being triggered.
    It works however if i house all the "Lefts" in their own If Then statements. Same goes with all the "Rights", "Ups" and "Downs".

    Could someone provide insight into this rather annoying problem?
    thanks.
    Last edited by squrrilslayer; May 3rd, 2008 at 04:29 AM.

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