Results 1 to 12 of 12

Thread: [2005] No error in code but freezing...

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2008
    Posts
    95

    Resolved [2005] No error in code but freezing...

    Yes i have been asking for help quite alot but this is just wierd! Take my code below:
    vb Code:
    1. Private Sub ItemSpawner_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ItemSpawn.Tick
    2.         Dim Spawn, X, Y As Integer
    3.         Dim Item As PictureBox
    4.         Dim Placeable As Boolean
    5.         Dim Objects As Control
    6.         Placeable = True
    7.         Randomize()
    8.         Spawn = (Rnd() * 20 + 1)
    9.         Background.SendToBack()
    10.         Select Case Spawn
    11.             Case Is = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
    12.                 'FireBall
    13.                 Do
    14.                     Item = New PictureBox
    15.                     Item.Image = Image.FromFile("FireBall.gif")   '<<<--- Also Freezes at this point sometimes.
    16.                     Item.Width = 26
    17.                     Item.Height = 30
    18.                     Controls.Add(Item)
    19.                     X = (Rnd() * 760 + 1)
    20.                     Y = (Rnd() * 560 + 1)
    21.                     Item.Location = New Point(X, Y)   '<<<--- Freezes at this point on repeat!
    22.                     Item.Tag = "Item Fireball"
    23.                     For Each Objects In Controls
    24.                         If TypeOf Objects Is PictureBox AndAlso Objects.Tag = "wall" Then
    25.                             If Objects.Bounds.IntersectsWith(Item.Bounds) Then
    26.                                 Placeable = False
    27.                             End If
    28.                         End If
    29.                     Next Objects
    30.                 Loop Until Placeable = True
    31.                 Item.Visible = True
    32.         End Select
    33.     End Sub

    It runs the code 1st time well but on the loop it freezes. So it'll place the object fine and it it does not collide with anything, the code passes on and all i well. However if the object the placed and it collides, i tell it to reposition be looping the code again. This causes problems... the program just Freezes! No error, just freeze!

    I just cant see what is causing this. To me, the code although not Perfect, should work.

    can anyone see what is wrong with it?
    If requested, ill pm source files since this is my groups assignment.
    Last edited by squrrilslayer; Apr 3rd, 2008 at 09:11 PM.

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