Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Moveable Objects
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
plzwork




PostPosted: Tue May 09, 2006 8:54 am   Post subject: Moveable Objects

Hey guys, I'm new here. Great site though!

I'm working on a VB project for school that consists of tools that would help one manage a restaurant.

One of the things I'd like to include is customizable floor plans. Thus meaning I'd need code that allows objects(pretty much a circle representing a table) on my form to be movable. I would also like for the user to have the ability to enter in the number of tables that will appear and these same tables(circles on the form) will be moveable.

Therefore I was wondering if anybody knows how to make it possible for objects on a form to be moved during run time and or the ability to enter in the amount of tables that will appear during runtime.

Thanks alot guys!
Sponsor
Sponsor
Sponsor
sponsor
pavol




PostPosted: Tue May 09, 2006 7:30 pm   Post subject: (No subject)

what you'll need to do first is be able to change the amount of tables present. for that you should create a control array. to do that just create your shape, lets say shpTable, as an array so its name should be shpTable(0). to make more tables appear during runtime you can then load a new object like so:
code:
'load the object
Load shpTable(the next number in the array. 1 in this case)
'make it visible
shpTable.Visible = True
'set its position on your form
shpTable.Left = 1000
shpTable.Top = 1000

for the movement of the tables, i don't know how to be able to move it with the mouse, but you can have the table activate itself when the shape is clicked and then move it around with the arrow keys on the keyboard
if you need something cleared up just post
hope it helps
cool dude




PostPosted: Tue May 09, 2006 8:24 pm   Post subject: (No subject)

there are several ways you can move it with the mouse. here is a little example. make a circle on your form and call it shpcircle. then double click on your form and choose mouse down. then just type in the code. everytime you click on the screen the circle will follow where the last click was.

code:

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    shpcircle.Left = X
    shpcircle.Top = Y
End Sub
wargamer17




PostPosted: Sun Apr 15, 2007 11:36 am   Post subject: Re: Moveable Objects

I know this is old, but you can easily move the object with the mouse without having to click where you want it to move to by using this code:
code:

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    shpcircle.Left = X
    shpcircle.Top = Y
End Sub
octopi




PostPosted: Sun Apr 15, 2007 3:10 pm   Post subject: Re: Moveable Objects

A. This post was a year old.

B. You added nothing, you just copied the code that cool dude had already posted over a year ago.
wargamer17




PostPosted: Tue May 08, 2007 9:02 pm   Post subject: Re: Moveable Objects

Whoops. What i meant to say was:
code:

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    shpcircle.Left = X
    shpcircle.Top = Y
End Sub
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: