Programming: VB Programming Tutorial #4

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
User avatar
Locke




Socialist Advisor Translator

Posts: 2225
Joined: Fri Aug 06, 2004 1:42 am
Location: Woot.com
Contact:

Programming: VB Programming Tutorial #4

Post by Locke »

Whoa! Its been a long time since I wrtoe another tut. Expect more to come shortly after this.

In this tut, you will learn to make objects move around the screen using Command buttons.

Start off by making a new project. Standard Exe
Image
Now that you have the form made. Change the name to

Frm1

Your welcome to change it to anyname you want. Also, feel free to change the caption

Now, go over to shapes in your toolbox. And drag out a shape onto the form. You cannot select the shape first. So it automaticly gives you a square
Image
Now that you have that done. Rename the shape to
Shp1

' Shape = Shp

And go down to Shape under Properties. Change the shape to Circle
Image

Now its time to make the command buttons. Arrange them to line up like the arrows of your keyboard.(See pic)
Image
Now its time to name them
The command button for up's name should be
cmdup
And the command button for down's is
cmddown
And so on.......
Now that the UI is set up. Its time for some code. The code is pretty straightfoward

Open up the code for cmdup. Type

shp1.top=shp1.top-100

Now to break it down. Shp1.top means. Shp 1's top properties.
Shp1.top=Shp1.top-100 means find shp1.top's current position, and minus that by 100 pixels. Normaly + means to go up, and - to go down. But VB is different. 0,0 on the form is at the top left corner. Not the bottom left corner like a graph.

Now open the code for cmddown. Use
shp1.top=shp1.top+100

Properties in vb are only Top, and left. There is no right, or down

Now open the code for cmdleft. Use
shp1.left=shp1.left-100
Again, same as the top

Again, open cmdright's code. And type
shp1.left=shp1.left+100

Now open the code for cmdexit. Use
Unload Me

Thats to shut the program down
Image

Wthe program runs. Click on the command buttons to move the shaps. You have to click them multiple times to get it to move far. But you could always increase to number from 100 +
Image

Well, sry for the delay. I get busy sometimes. Expect more tuts very soon. For now
Enjoy!
Image
Feel free to send me an instant message if you need anything.
Pie





Posts: 2690
Joined: Wed Mar 10, 2004 8:46 am
Location: Bedford \ Nashua, New Hampshire
Contact:

Post by Pie »

Any tutorial made, makes me learn.

I know nothing about making stuff like that.

Thanks!
Image
Thank You, SHOUTrvb, For This Fantastic Signature :mrgreen:
[users]TheKeihatsu





Posts: 19
Joined: Mon Oct 25, 2004 5:39 pm

Post by [users]TheKeihatsu »

its cool, this would help those people who want to make a game, instead of using command buttons you could use the keypress method that is built into each form and have it move around via the arrow keys, then you could make a simple game, like snake or something. Just an idea for people who want to put what they learned to the test. Good tutorial
Signature exceeded 75KB.
Sentinel





Posts: 420
Joined: Thu Nov 04, 2004 1:18 pm

Post by Sentinel »

awesome dude. im taking programing in 10th grade prolly so this will help me on my way to not having to pay attention alot of times in class like in everything else. :lol:
I don't have a sig....
kaptainkommie




Wordewatician 500

Posts: 732
Joined: Wed Nov 26, 2003 11:59 pm
Location: Raleigh, NC, USA

Post by kaptainkommie »

It probably won't help you too much, most schools are smart enough not to teach Visual Basic to students. They'll teach C++ or Java.
Thebirthdayhat





Posts: 94
Joined: Mon Nov 15, 2004 7:01 pm
Location: over there

Post by Thebirthdayhat »

TheKeihatsu wrote:its cool, this would help those people who want to make a game, instead of using command buttons you could use the keypress method that is built into each form and have it move around via the arrow keys, then you could make a simple game, like snake or something. Just an idea for people who want to put what they learned to the test. Good tutorial
if any1 wants to no how to do that with the keys i can help them. i learned it a while ago, i think yomama taught me.
btw great tutorial! that will help out alotta ppl. make another 1 on making a character shoot and making it kill people. or sumthing
then a buncha ppl will be making games and maybe there will be sum good 1s made.
Signature exceeded 3 lines of text.
Sentinel





Posts: 420
Joined: Thu Nov 04, 2004 1:18 pm

Post by Sentinel »

that would proly end up like the halomods browser thing though and make it suck. also kptkommie, y would they teach C++ to ppl with no experience of programing?
I don't have a sig....
[users]TheKeihatsu





Posts: 19
Joined: Mon Oct 25, 2004 5:39 pm

Post by [users]TheKeihatsu »

C++ and or java are not that hard, they teach them because thats what the AP tests are on.
Signature exceeded 75KB.
~{DE}~Demolisher





Posts: 100
Joined: Thu Dec 02, 2004 8:35 am
Location: MS,USA
Contact:

Post by ~{DE}~Demolisher »

Yomama you are da bomb may your life be filled with joy lol.
Signature exceeded 75KB.
Cheech|N|Chong





Posts: 115
Joined: Fri Jan 14, 2005 9:26 am
Location: Why The Fuck Would I Tell You? Indiana...
Contact:

Post by Cheech|N|Chong »

great tut yomama, have a dolla
Signature exceeded 75KB.
[CL]9mm-Man




Wordewatician 500

Posts: 773
Joined: Tue May 04, 2004 7:14 am
Location: Uranus

Post by [CL]9mm-Man »

Neat tutorial, Ill do in soon..Probably make a drawing program out of it as wel..
Your image cannot exceed 400x200 or 50kb
Post Reply