Visual Basic - Drag and Drop

I am working on a game mimicking score simulator where you can drag around robots and bins and get scores, but i’m haveing trouble with the drag and drop part.

When I only set the forum to allow movement for one object

Source.Move X, Y

Then things work fine, but when I set the forum to allow movement for two or more objects

Source1.Move X, Y
Source2.Move X, Y

Then when I drag either object Source1 is in the drop positon and Source2 is nowhere to be found.

I’m clueless, and can’t find a tutorial or forum with the answer, PLEASE HELP!!!

on a form not forum right? Are you setting both objects to drag mode=automatic?

i am considering making a web based scoring simulator for everyone. Tell me how ur sim goes. Can u post it when ur finished¿

This is my program, except for the positioning junk, it dosent work in vbManual or vbAutomatic.

Private xoffset As Integer
Private yoffset As Integer
Option Explicit

Private Sub ba_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xoffset = X
yoffset = Y
ba.Drag vbBeginDrag

End Sub

Private Sub bb_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
xoffset = X
yoffset = Y
bb.Drag vbBeginDrag

End Sub

Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
bb.Move (X - xoffset), (Y - yoffset)
ba.Move (X - xoffset), (Y - yoffset)

End Sub

ya, if i finish this, i’ll pass it out to whoever wants it.

What I’d like to see is a version with 4 “players” just like the real game so 4 people can use the program at once. This would be okay with the current game simulator too. Am I making sense?

The final version will have 4 robots…i just put up the code(only has 2 bots now) in hopes that someone would see what i’m doing wrong.

umm ya, just do this

Turn DragMode automatic whatever in the properties window, right then on the place where it lands, use the drag drop event and get the object that was dropped with the parameter.

I would give you a more accurate description of how to do this but I was too lazy to open VB. This should work, if it doesn’t then I’ll tell you how to fix it, or send you a sample.

DragMode = Automatic
Object receiving event DragDrop, in that event do your stuff
k

Bleah, I dont use MOVE either
I jsut do object.left
object.top =
because if you use X and Y, it does placements based on your desktop I think ya thats it

sry, just a cheap lazy message trying to fix some c++ bug

  • Ryan Waliany

I’m not really following you. I’m trying to simply drag an objecct and make it stay where it was droped, I can manage to do it with one objeect, but not with multiple ones.

What do you mean one, and not others? Do you have Aim, Icq, MSN, or Yahoo. I could probably explain it better on one of those.
Aim: Ryan Waliany, Icq: 11032544, MSN, [email protected], yahoo Ryan_waliany

Source code of VB proj which does it…

sample drag.zip (661 Bytes)


sample drag.zip (661 Bytes)

From what you have said, it appears that your code may be moving both objects when you only click and drag one. The destination would be in the same place with one object completely covering the first.

thanx every1 who helped me, i finaly fixed the problem