Programming: VB Programming Tutorial #5

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 #5

Post by Locke »

I got some more time, and have decided to write another tut. This one is a little more advanced. There going to be more advanced as time progresses.

Today, you will learn about "If" statements. An If statement is basicly saying, if this happens then do this. So in Halo terms, If the Mc gets Killed then mc respawns. Simple enough eh?

So, as always, make a new Standard Exe project. Keep the form name the same and change the caption to "If Statements".

Image

Now that you have completed this, lets put some objects on. Draw out a label, and set the caption to "Wich is better. Halo2 or Half-life 2?'. Then draw out 2 options onto the form. Name them opt1 and opt2. After, make a command button and change the caption to "Submit"

Image

Now for the coding. Double click Command1 to bring up the code. Use

Code: Select all

If opt1.Value = True Then
MsgBox "Woot", vbExclamation, "Halo2"
End If

If opt2.Value = True Then
MsgBox "Not Woot", vbExclamation, "Half-Life 2"
End If
Image

So "If Opt1.value = true then" means If you selected Option1 then do something.
The msgbox is what it does when the first line/condition happens. And the last line "End if" means the If statement is over. The code wont work without it.

Also, the above coding could be writtin in an If-Then-Else format. Here's an example:

Code: Select all

If opt1.Value = True Then
MsgBox "Woot", vbExclamation, "Halo2"
ElseIf opt2.Value = True Then
MsgBox "Not Woot", vbExclamation, "Half-Life 2"
End If
So now run your program.

Image

So this is the basics of the If statement. Its a powerful line of code.....
Ill release more tuts in a few hours/days.
Last edited by Locke on Tue Jun 21, 2005 7:37 pm, edited 1 time in total.
Image
Feel free to send me an instant message if you need anything.
TfAv1228




Miner Logistician Droplet

Posts: 276
Joined: Sun Sep 05, 2004 4:40 pm

Post by TfAv1228 »

LOL extremely simple but nice for beginners
Sig breaks rules, read the rules before reposting.
Jefff




Socialist Miner Logistician Snitch!
Critic Droplet

Posts: 244
Joined: Sun Oct 24, 2004 5:59 pm

Post by Jefff »

Also, the above coding could be writtin in an If-Then-Else format. Here's an example:

Code: Select all

If opt1.Value = True Then
MsgBox "Woot", vbExclamation, "Halo2"
ElseIf opt2.Value = True Then
MsgBox "Not Woot", vbExclamation, "Half-Life 2"
End If
How to Post Correctly
SWYgeW91IGNhbiByZWFkIHRoaXMgeW91IGhhdmUgd2F5IHRvIG11Y2ggdGltZSBvbiB5b3VyIGhhbmRz
~{DE}~Demolisher





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

Post by ~{DE}~Demolisher »

Awsome tut yomama! When i 1st got vb i thought it was really hard but then i did your tuts 1-3 and it was really easy and im a pretty good programmer now.Thx for the tuts im sure every1 appreciates them.
Signature exceeded 75KB.
Onetoomanysodas





Posts: 325
Joined: Mon Mar 22, 2004 3:59 pm
Location: Everywhere but nowhere
Contact:

Post by Onetoomanysodas »

Nice tut,

~*AUGH*~

--> I just got back from modding camp and wow i'm like really out of it but it was fun!

But yeah I also did some j-sharp (j#) programming and other java and this is so much simpler than doing it in java.
User avatar
JK-47




Bloodhound Pyre Socialist Grunge

Posts: 10883
Joined: Wed Dec 01, 2004 2:54 pm
Location: Utah

Post by JK-47 »

once again, nice tut :D

but i like half life :x

so i made it a poll with halo and halo 2 lol

here, try it out, its funny

http://rapidshare.de/files/6342392/vote.exe.html

im sorry its rapidshare but i forgot my filefront account and i didnt want to make another one or have them email me my pasword cause im too scared to look at all the spam in my inbox :shock:

click both the options on it, they are both funny

(oh yomama, the next tut should be on how to make a mod program if at all possible, just a very basic one, if you know how to do it because i would REALLY like to know how to do taht :wink: )
Image
Post Reply