2 Replies - 2050 Views - Last Post: 18 November 2011 - 07:02 AM Rate Topic: -----

#1 zukeru  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 160
  • Joined: 25-December 09

How do I detect Picture box collisions in VBA?

Posted 17 November 2011 - 08:17 PM

I build a game in excel visual basic but I cant seem to detect collisions. Anyone have any idea how to do this


Sub Form1_KeyDown(allthestufftodetectwhichkeyisbeingpressed)
if left = char("leftasciichar") then
image.left = image.left -10
end if
dim widthleft as integer
dim height as integer
if image11.left >= image2.left then
widthleft = image2.left + image2.width
if image11.left <= widthleft then
if image11.top >= image2.top then
height = image2.top + image2.heaight
if image11.top <= height then
msgbox("you ahave hit the bounds")
end if
end if
end if
end if
end sub

this doesnt work though if anyone knows how to detect collision in vba which is excel vb.
i cant use vb6 syntax because vba doesnt have all the syntax which is why i have to use the multiple if then statements
anyone know.

Is This A Good Question/Topic? 0
  • +

Replies To: How do I detect Picture box collisions in VBA?

#2 zukeru  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 160
  • Joined: 25-December 09

Re: How do I detect Picture box collisions in VBA?

Posted 17 November 2011 - 08:27 PM

or rather how do i make a loop function to determine if its left is between two ranges ie
dim leftright as range 1 to 15
if image.left = leftright then
do this
end if


is that even possible
Was This Post Helpful? 0
  • +
  • -

#3 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: How do I detect Picture box collisions in VBA?

Posted 18 November 2011 - 07:02 AM

Here's a loop that will stop when you go off the left edge of the form:
Do Until Image.Left <= 0
    Image.Left = Image.Left - 1
Loop

Maybe that will get you started?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1