Programming: The Very Basics (VB2005 Express) Part 1

This is where the Admins will put tutorials submitted by users.
Post Reply
Strang3r





Posts: 149
Joined: Sun Feb 05, 2006 9:36 am
Location: Cardboard Box

Programming: The Very Basics (VB2005 Express) Part 1

Post by Strang3r »

Well as we all know everyones gotta start somewhere, so this tut will cover the basics of programming,

We will be using 'Visual Basic 2005 Express Edition'

1) When the program loads up you will find yourself on the startpage, to start a new project use the button in the top-left
Image

2) Select windows application
Image

3) The box at the bottom should now contain the words 'Windows Application1', change this to 'Organiser' as this is what we will be making. Click OK

4) You'll screen will now change around, you are now in the designer :) , you will have a form in the middle-left of the screen
Image

A properties window in the bottom-right
Image

A solution explorer in the top-right
Image

And error, warning and message lists at the bottom
Image

All these windows can be moved around and resized to your liking with the mouse :)

You may have also noticied that each window can also be closed, if at anytime you wish to reopen a window just use the 'view' menuitem at the top and select the window from the dropdown
Image

5) 1st of all i will tell you how to save and distribute your app, around the top-left you should see a little button that looks like this: Image

Click it, this window should appear:

The 1st box is the name of your .exe, the 2nd box is the location it saves too and the 3rd box is the name of your project,

Fill out the information accordingly

Note: If this Image is checked and the location you enter in the 2nd box doesnt exist then it will be made

Now whenever you wish to save just click Image

6) Press F5 to enter 'debugging mode', all this does is compile your app so you can test it out, exit 'debugging mode' by clicking the red X on your app

You can alternatively enter/exit 'debugging mode' through the 'debug' menuitem
Image
-----------
Image

Compiling: This means that vb takes your project and converts it into numbers and letters which the computer can then understand, read and act accordingly, these numbers and letters are called binary

7) Open up the folder you saved your project to -> Go into the next folder -> Bin -> Debug; your compiled .exe will be here, this .exe is your app, it is remade everytime you press F5 in vb
Image

8) At the moment the app looks pretty crap so back in vb, doulble-click 'My Project' in the solutions explorer, another window will now come up with around 10tabs on the left, for now we'll just be worrying about the 1st tab

Just to name a few things: the 'Assembly Name' is the name of the project and the 'Root Namespace' is the name the app refers to itself as.

1st of all I'll show you how 2 change the the apps icon, there will be a dropdownbox with the word 'Icon' above it, open it up and select 'browse'
Image

Browse through your PC until you find a suitable Icon (The FastIcons download page offers some pretty good ones: http://www.fasticon.com/downloads.html)

Save once you've done that, press F5 to compile, now you can go back into the 'bin' folder and see what it looks like :)

You will also notice that there is a line of text under the name that is slightly faded
Image

it is possible to change that and furthermore add another line of text under that, back in vb click Image to bring up another window
Image

Once youve changed that, save and compile your app again and then check it out in the bin folder :)
Image

9) Right, time to actually begin coding! Close down the 'My Project' Window so you can see your Form again, by default it is called form1

Click it, when you do you'll see the items in the 'properties window' will change, these are the properties of the form, this is where you can change its text, colour, size, location, style, visibility etc
Every item will have properties

The 1st thing an organiser needs is a button, we will use this to launch another program. To get a button you will need to open up the toolbox by clicking Image (top-right), the toolbox will appear on the left, as you can see there are loads of tools, all we will be usin though is the button, click an drag it onto the form

So now your form has a button, double-click the button and you will be brought to another window that should contain this code:

Code: Select all

Public Class Form1

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

	End Sub
End Class
1st of all you must keep in mind that everything that has a beginning, must has an end

The 1st line of code (Public Class Form1) is ended by (End Class) as is (Private Sub) with (End Sub)

Any code that goes inbetween:

Code: Select all

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

	End Sub
Will be used when the button is clicked, we know this because the last couple of lines tells us what it handles

Code: Select all

Handles Button1.Click
Every item has a default handle, the button is button.click, but do not think that that is its only handle, god no, we'd get nowhere otherwise! Going back to the designer, this time just click the button once, now in the properties box there will be a button like: Image, Click it. The properties window will now display something else, it will display a list of all the different handles the button can take, I will go more into this in a further lesson, for now all we need is button.click

So go back to the code window and put in the button1.click handle:

Code: Select all

Process.Start("filepath") '<-- Replace filepath with a program from your PC
So your code should now look like:

Code: Select all

Public Class Form1

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Process.Start("filepath") '<-- Replace filepath with a program from your PC
	End Sub
End Class
Note: As you can see i have added '<-- Replace filepath with a program from your PC, if you copied this into your code you will notice it is a green colour, this is because it is a comment, you start a comment by simply putting an apostrophe at the start of the sentence, the app wont read this code, its just there so you remember what things are doing :)

10) Press F5 and click the button, the program you chose should now come up, well done! you just made a basic organiser :)

I will be bringing out another tut soon that will cover more advanced basics, until then post any questions you may have on this.

One last thing is for other people to run your app they will need .net framework 2.0, this is just more advanced than 1.0/1.1. All it really is is a program running tool -> Download Page
VoYdE





Posts: 1474
Joined: Sun Aug 14, 2005 11:39 pm
Location: On Vacation From The Loads Of Bull*hit That Goes On Here
Contact:

Post by VoYdE »

Very Nice! 9/10 You Should Demonstrate How To Write Your Own Code

EDIT Nevermind (Just Saw Part 2) LOL(8)

Love The Photos
Last edited by VoYdE on Tue Mar 14, 2006 5:29 pm, edited 1 time in total.
Image
I made this 100% by myself, Everything from the background, to the location of the tags, Get yours http://customgamercards.com
User avatar
dos mes





Posts: 2158
Joined: Thu Dec 29, 2005 9:58 pm
Location: Syracuse, NY

Post by dos mes »

Voyde you're such a spamming hoe lol. I like how you told him to write a tut on writin your own code when it was right above this and you posted this after he posted that by hours lol. :wink:
Doctor





Posts: 567
Joined: Sun Nov 27, 2005 5:48 pm

Post by Doctor »

NICE! I've been looking for this, 10/10.

This diserves a sticky.
Image
Communism || Well in Halomods Com, I own you. -Shout
Userbar put your total signature image at 140 pixels in height. Sorry. <-- My sig has become the #1 place for Moderator tags -_-
You could always, oh I don't know, edit our comments out? =p | I would put it back in. -Shout -wer its at brudda-
Kurroda





Posts: 1737
Joined: Sat Sep 03, 2005 10:01 am
Contact:

Post by Kurroda »

yes man very nice
Image
Post Reply