Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
need help in visual basic?
I am working on a simple project where I make a car move in different directions and at different speeds. I have figured all of that out but have a really big problem.
My teacher wants me to have the car wrap around when it reaches the end of the screen. For instance, if the car went all the way in the up direction out of the screen, he wants it to come from the bottom of program. And if it goes all the way in the left direction out of the screen, he wants it to reappear from the right side, moving left still.
Is there a common chain of commands or script that could help me accompish this? I know I am being very broad in this, but I don't know how to explain it better. I am very baffled on how I am ever going to accomplish this.
I know it might involve using Me.Width and Me.Height, but I am unsure on how to begin at all.
Where do i write those commands? how do i set window borders? I am very new at this
Also, how do i check what Me.width and me.height are? Ive typed it in the code and it doesn't do anything productive.
I am just lost
2 Answers
- 1 decade agoFavorite Answer
Window borders are:
Left: Left=0
Top: Top=0
Right: Left=Me.Width
Bottom: Top=Me.Height
if the Left of the car is more than Me.Width then it crosses the Right border, so set it to the left border. if the Left of the car is lower than 0, it crosses the Left border, so set it to the right. If the top of the car is lower than 0 it crosses the top of the screen, so set it to the bottom (top=me.height). if it crosses the bottom, set it to the top.
Maybe you will need to substract the width/height of the car, it depends on the situation and what exactly you want to achieve.
- Anonymous1 decade ago
You need to handle user input, that will be either by mouse or key board, I'd go for keyboard that should make it a bit easier.
You need to capture the keypress events on the form (or maybe one of the others). Or it may be another drawing surface within the form e.g. picture box.
Break the code in the event and see what the key values are for the arrow presses, that will tell you which ones are the arrows easily, better than looking through help.
You need to redraw the car at each key press.
Me.Width and Height are properties, they are values, they don't make anything happen they just give you information.
If you're lost at this point then the task is way too hard for you. You don't have the basic skills and knowledge required to complete it.