Programming: VB Programming Tutorial #1
Programming: VB Programming Tutorial #1
Well,alot of people are still in the dark when it comes to programing.So this is a tut to get people started.
Today,you will learn Visual Basic.Oooooooh,the excitement
First you will need vb,found here.
http://www.microsoft.com/downloads/deta ... layLang=en
Dl and install.
Now for the learning part.
Open vb and select Standard exe
It should now look like this
That is a Form.Thats where to entire program takes place.You can expand and minimize it.
This is your tool bar.This is where you can select controls.Liek command buttons,text boxes,and labels
And this is the Properties box.This is where you change everything thats in the object selected.
That was the basic introduction.So you know what Im talking about
Now the fun begins
Notice that the forms label says Form1.You probably dont want that in your program so lets change it
Click on the form and go into properties.Go down to caption and it should say Form1
For now,change it to Test
You just changed the title.Hurray!
Now lets change the name.In vb there is abriviations.Heres a list of them
Form=frm
Label=lbl
Text Box=txt
Shape=shp
Picture Box=pic
Image Box=img
Timer=tmr
Option=opt
Cammand Button=cmd
Those are the basics of abriviations.So lets put them to use
Click on your form and go into properties.Go to the top where it says (Name)Form1
change it to frm1
Not much of abriviation there.But helps you in the long run.
Now gray may not be your color of choice.So to change the background color go down to BackColor in the properties window.Click on the gray color til a box comes up.That box has all the colors you can use.Select the one you want and click on the form.It should now be the color.
So lets make a very simple program
Go to your tool box,and select the command button icon.If you are unsure what one this is.Hold your cursor over each one,and it will say what it is.
Drag the commandbutton onto the screen.
It should now look similar to this
Click on the button once.Then go to properties and go to name
Rename to
cmd1
Go down to caption and type
HI
Now double click on the command button.It brings up the code.It now looks like this
Now in there type
msgbox"Hello World!",vbexclamation,"Message"
Now to break that down
msgbox stands for message box
The first quotations "Hello World!" is what the messgae box will say when it pops up.
The vbexclamation is the icon the message box will have.In this case,an Exclamation mark.
And the last quotes "Message",is what the title for the message box will say.
Now press F5 to run the program
Click on the command button that says Hi.It should look like this
Note my title for the message box didnt come up.Thats because Im not using a regular Windows skin.Others will work though
To stop the program click on the icon
Now you may be wondering.How do I see my form again?Above the properties window there is another window.In that,it should say Frm1.Double click frm1 and it will take you back.
Thats it for this part of the tut.Feedback if you want more
Part 2
Well I finaly got enough time to write another tut.Sry to leave you guys hanging with the last one.With that said,lets begin
I will assume you know the basics by following the Visual Basic Programming Tutorial #1 so I wont have to repeat myself
Today,you will be learning something a bit more comlicated.But still easy.You will be learning how to make your own web browser.
Open vb and select Standard exe.Drag out the form so it looks like this
Go over into the properties menu and change the name Form1 to frmExplorer2
Then change the caption to Explorer 2
Not hold control and press the letter "T"
A menu should appear.Scroll down to Microsoft Internet Controls.Check the box and click ok.
Now a picture of the world has been added to your tool box.
Click on it,and drag it out onto the form.
Now clcik on a text box,and drag it out onto the form.
Click on the txt box and go down in the properties menu to Text
Change it from "Text1"to " "
Now drag out a command button onto the form.Change the name from "Command1" to "cmdgo"
Now change the caption to "Go!"
Looks kinda familiar now.
Now for the coding wich is very simple
Double click cmdgo
Now type
WebBrowser1.Navigate Text1.Text
Press F5 to run the program.Type the url into the textbox and press Go!
And thats a web browser.But if you want to create a little bit more.Continue on
Create a new command button and name it cmdback.Then change the caption to "Back"
Then add another command button and name it cmdforward.Then change the cpation to "Forward"
Double click on cmdback and type
On Error GoTo Error
WebBrowser1.GoBack
Error:
Exit Sub
Then double click on cmdforward.And type
On Error GoTo Error
WebBrowser1.GoForward
Error:
Exit Sub
Now when you are in the explorer,you can go back,and forward.
That ends this tut.Ill post more when I get my next break.Feedback please
Part 3
This one will be more Halo orientated.I will explain how to make a simple program like this.
http://files.halomods.com/viewtopic.php?t=18487
Just got it moved to utilities,people spammed last one.
Im going to again asume you have read the previous tuts.
To start off make a form.Name it frmmain
Change caption to Halo Dedicated Server Program
Make a textbox on the form,and name it txt1.Go down to text and delete it.Go to Multiline,and say True(makes it type on more than 1 line)
Now that you have that,lets create some labels
Drag out a label and place it on screen.Change caption to
Server Name
Make a new label and change caption to Maxplayers
Make a new label and change caption to Maps
Make a new label and change caption to gametypes
And creat a command button called submit
cmdsubmit
Caption=Submit
Now create a txtbox,name it txtname,and delte the text from it.Place it next to the label that says Server Name
Create another textbox and name it txtmaxplayers,and delete all text,And place by label Maxplayers
Create another textbox and name it txtmap,and delete all text,And place by label Map
Create another textbox and name it txtgametype,and delete all text,And place by label Gametype
Now for some coding
type
txt1.text="sv_name "+""""+txtname+""""
'That says,type sv_name then add a space,and put "" around the name the user typed in.
So txt1 will say
sv_name "Test"
go down a line anf type
txt1.text=txt1.text+vbcrlf+"sv_maxplayers "+txtmaxplayers
You dont need the "" around it cause its a number
txt1.text=txt1.text,that means add this to the current txt1(otherwise,it would delete what you said,and qrtie new text)
vbcrlf just makes it go to next line
now go to next line and type
txt1.text=txt1.text+vbcrlf+"sv_mapcycle_add "+txtmap+" "+txtgametype
Longer code there,cause it combines txtmap,and gametype together
Now run and type Name,maxplayers,map,and gametype.
And thats the basics of my program.Youll have to mess around a bit to put in more stuff.
All the dl's for vb trial have disapered and I cant find them.Search google for
Visual Basic 5.0 Control Edition
if you find a link please post it here
Any suggestions for another tut?
Part 4
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
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
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
Now its time to make the command buttons. Arrange them to line up like the arrows of your keyboard.(See pic)
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
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 +
Well, sry for the delay. I get busy sometimes. Expect more tuts very soon. For now
Enjoy!
Today,you will learn Visual Basic.Oooooooh,the excitement
First you will need vb,found here.
http://www.microsoft.com/downloads/deta ... layLang=en
Dl and install.
Now for the learning part.
Open vb and select Standard exe
It should now look like this
That is a Form.Thats where to entire program takes place.You can expand and minimize it.
This is your tool bar.This is where you can select controls.Liek command buttons,text boxes,and labels
And this is the Properties box.This is where you change everything thats in the object selected.
That was the basic introduction.So you know what Im talking about
Now the fun begins
Notice that the forms label says Form1.You probably dont want that in your program so lets change it
Click on the form and go into properties.Go down to caption and it should say Form1
For now,change it to Test
You just changed the title.Hurray!
Now lets change the name.In vb there is abriviations.Heres a list of them
Form=frm
Label=lbl
Text Box=txt
Shape=shp
Picture Box=pic
Image Box=img
Timer=tmr
Option=opt
Cammand Button=cmd
Those are the basics of abriviations.So lets put them to use
Click on your form and go into properties.Go to the top where it says (Name)Form1
change it to frm1
Not much of abriviation there.But helps you in the long run.
Now gray may not be your color of choice.So to change the background color go down to BackColor in the properties window.Click on the gray color til a box comes up.That box has all the colors you can use.Select the one you want and click on the form.It should now be the color.
So lets make a very simple program
Go to your tool box,and select the command button icon.If you are unsure what one this is.Hold your cursor over each one,and it will say what it is.
Drag the commandbutton onto the screen.
It should now look similar to this
Click on the button once.Then go to properties and go to name
Rename to
cmd1
Go down to caption and type
HI
Now double click on the command button.It brings up the code.It now looks like this
Now in there type
msgbox"Hello World!",vbexclamation,"Message"
Now to break that down
msgbox stands for message box
The first quotations "Hello World!" is what the messgae box will say when it pops up.
The vbexclamation is the icon the message box will have.In this case,an Exclamation mark.
And the last quotes "Message",is what the title for the message box will say.
Now press F5 to run the program
Click on the command button that says Hi.It should look like this
Note my title for the message box didnt come up.Thats because Im not using a regular Windows skin.Others will work though
To stop the program click on the icon
Now you may be wondering.How do I see my form again?Above the properties window there is another window.In that,it should say Frm1.Double click frm1 and it will take you back.
Thats it for this part of the tut.Feedback if you want more
Part 2
Well I finaly got enough time to write another tut.Sry to leave you guys hanging with the last one.With that said,lets begin
I will assume you know the basics by following the Visual Basic Programming Tutorial #1 so I wont have to repeat myself
Today,you will be learning something a bit more comlicated.But still easy.You will be learning how to make your own web browser.
Open vb and select Standard exe.Drag out the form so it looks like this
Go over into the properties menu and change the name Form1 to frmExplorer2
Then change the caption to Explorer 2
Not hold control and press the letter "T"
A menu should appear.Scroll down to Microsoft Internet Controls.Check the box and click ok.
Now a picture of the world has been added to your tool box.
Click on it,and drag it out onto the form.
Now clcik on a text box,and drag it out onto the form.
Click on the txt box and go down in the properties menu to Text
Change it from "Text1"to " "
Now drag out a command button onto the form.Change the name from "Command1" to "cmdgo"
Now change the caption to "Go!"
Looks kinda familiar now.
Now for the coding wich is very simple
Double click cmdgo
Now type
WebBrowser1.Navigate Text1.Text
Press F5 to run the program.Type the url into the textbox and press Go!
And thats a web browser.But if you want to create a little bit more.Continue on
Create a new command button and name it cmdback.Then change the caption to "Back"
Then add another command button and name it cmdforward.Then change the cpation to "Forward"
Double click on cmdback and type
On Error GoTo Error
WebBrowser1.GoBack
Error:
Exit Sub
Then double click on cmdforward.And type
On Error GoTo Error
WebBrowser1.GoForward
Error:
Exit Sub
Now when you are in the explorer,you can go back,and forward.
That ends this tut.Ill post more when I get my next break.Feedback please
Part 3
This one will be more Halo orientated.I will explain how to make a simple program like this.
http://files.halomods.com/viewtopic.php?t=18487
Just got it moved to utilities,people spammed last one.
Im going to again asume you have read the previous tuts.
To start off make a form.Name it frmmain
Change caption to Halo Dedicated Server Program
Make a textbox on the form,and name it txt1.Go down to text and delete it.Go to Multiline,and say True(makes it type on more than 1 line)
Now that you have that,lets create some labels
Drag out a label and place it on screen.Change caption to
Server Name
Make a new label and change caption to Maxplayers
Make a new label and change caption to Maps
Make a new label and change caption to gametypes
And creat a command button called submit
cmdsubmit
Caption=Submit
Now create a txtbox,name it txtname,and delte the text from it.Place it next to the label that says Server Name
Create another textbox and name it txtmaxplayers,and delete all text,And place by label Maxplayers
Create another textbox and name it txtmap,and delete all text,And place by label Map
Create another textbox and name it txtgametype,and delete all text,And place by label Gametype
Now for some coding
type
txt1.text="sv_name "+""""+txtname+""""
'That says,type sv_name then add a space,and put "" around the name the user typed in.
So txt1 will say
sv_name "Test"
go down a line anf type
txt1.text=txt1.text+vbcrlf+"sv_maxplayers "+txtmaxplayers
You dont need the "" around it cause its a number
txt1.text=txt1.text,that means add this to the current txt1(otherwise,it would delete what you said,and qrtie new text)
vbcrlf just makes it go to next line
now go to next line and type
txt1.text=txt1.text+vbcrlf+"sv_mapcycle_add "+txtmap+" "+txtgametype
Longer code there,cause it combines txtmap,and gametype together
Now run and type Name,maxplayers,map,and gametype.
And thats the basics of my program.Youll have to mess around a bit to put in more stuff.
All the dl's for vb trial have disapered and I cant find them.Search google for
Visual Basic 5.0 Control Edition
if you find a link please post it here
Any suggestions for another tut?
Part 4
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
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
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
Now its time to make the command buttons. Arrange them to line up like the arrows of your keyboard.(See pic)
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
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 +
Well, sry for the delay. I get busy sometimes. Expect more tuts very soon. For now
Enjoy!
Last edited by Locke on Tue Oct 26, 2004 3:08 pm, edited 1 time in total.
Feel free to send me an instant message if you need anything.
-
- Posts: 732
- Joined: Wed Nov 26, 2003 11:59 pm
- Location: Raleigh, NC, USA
-
- Posts: 225
- Joined: Thu Sep 16, 2004 2:21 pm
Yeah... um, the DL link is like... BROKEN. You mind fxing it?
EDIT: Yeah I recognize that sentence : hello world!. I know where you learned all that from, arg I am to lazy to search for i but try typing C++ tutorial into yahoo search and you get a few really nice tuts. Like from www.cplusplus.com
EDIT: Yeah I recognize that sentence : hello world!. I know where you learned all that from, arg I am to lazy to search for i but try typing C++ tutorial into yahoo search and you get a few really nice tuts. Like from www.cplusplus.com