►Visual Basic for Noobs◄ (For Beginners)

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
8 posts Page 1 of 1
Contributors
User avatar
zulfikar
Member
Member
Posts: 30
Joined: Fri Aug 19, 2011 4:22 am

This tutorial is for those who are just starting off.( COULD A MOD OR ADMIN PLEASE DELETE THIS...I WILL BE RE-MAKING IT LATER BETTER.

Visual Basic is a programming language made for those who are most visual learners and less coding needed. C++ is the language for full on coding. Though both can do the same thing, visual basic is a much simpler and easy language to learn. If you're into programming I suggest starting here. First off, an I.D.E is an integrated Development Environment. It is where you create your applications. Super Basics...COVERED!

INDEX:

Tutorial 1: Hello World

Tutorial 2: Basic Codes

[url="WILL COME LATER]Tutorial 3: Variables(Coming Soon)[/url]

OTHER TUTORIALS WILL ALSO COME...BOOKMARK THIS :D

DUE TO CERTAIN ISSUES>...I WILL BE MAKING TUTORIAL IN WORD AND UPLOADING IT LATER.

and pictures will come later...my visual basic is acting up so i did this by memory.
Last edited by zulfikar on Mon Mar 26, 2012 11:01 pm, edited 5 times in total.
Image
User avatar
zulfikar
Member
Member
Posts: 30
Joined: Fri Aug 19, 2011 4:22 am

Tutorial 1: Hello World

A Hello World tutorial is found everywhere, one of the most used ways to start off any language. Programming is not far behind in this tradition. Z STYLE!

I won't start off by showing you how to create a project or anything as anyone with a mind could learn that easily. Just create a new Project and click windows Application.

Now lets get into the coding part. From your toolbox, drag and drop a label on the Form shown when you create a project. click on the label and do you see the properties box on the side? If you haven't moved anything around you should be able to see it. Something similar to this :

Image

This box shows all the properties on the selected, Try fooling around with the properties and see what they do by yourself. Now let's move on. (Self-Explanatory what they do)

Once you have your label selected, go to your properties box and scroll to find the Name property. It should say Label1. Change it to lblHelloWorld. This is good practice when dealing with complex programs. It helps you easily identify its use when coding. Here are some prefixes we will use in these tutorials.

Name Prefixes :

Label = lbl
Button = btn
Textbox = txt
Picture = pic

REMEMBER : A NAME HAS TO BE ONE WORD AND NO NUMBERS!

Drag a button and name it to btnHello. Arrange your form the way you like.

Now when you double click the button it opens up where you will code it. The I.D.E automatically adds the class and event so for now, you don't have to bother with it.

Add this code :
Code: Select all
lblHelloWorld.Text = "Hello"
What this does is simple take the label we named and take its text property and change it to "Hello"

Why don't we modify it a little and make it more complex?

Drag a Menu Strip from the toolbox and it'll put itself on the top automatically. There'll be textboxes in which you can modify and add your own words. Double click the first box and type Program. After clicking it again it should show you a drop down box. Under Program type Exit and then double click the word exit after u typed it.

This brings up the Menu Strip code for your Exit option. In this you will put :
Code: Select all
Application.Exit()
I won't explain this as it is self-explanatory.

Summary :

In this you learned about properties of objects and the code for exiting out of a program as well as changing the text properties of a label.
Last edited by zulfikar on Thu Mar 22, 2012 12:53 am, edited 3 times in total.
Image
User avatar
zulfikar
Member
Member
Posts: 30
Joined: Fri Aug 19, 2011 4:22 am

Tutorial 2: Basic Codes

Let's just jump into tutorial 2. In this we'll learn basic codes. Basic codes is a general term for basic codes. Get ready! fight;

The first code we have is Closing and Opening a second form.

Go ahead and right click on your project list on the side. It'll have options such as add item. Click on Windows Form and get it ready. GO back to your first form and add a button. Name it btnForm2. We name buttons again for clean code and programming practice. In this button's class add the following :
Code: Select all
Form2.Show
This piece of code is there, well...to show the next form when the button is pressed.

Like that there is other codes as well such as
Code: Select all
Form2.Close
or even
Code: Select all
Form2.Show
Me.close
Me is always used when referring to self. If u say form1.close when the code is in form1 it'll give u an error similar to : you cannot refer to self like that.

You can easily also make the forms beg on their knees and do your bidding, but we'll leave that to later.

Our next code is adding/subtracting/dividing and the such.

Put a button and a label.Name the label lblanswer Double click the button and put :
Code: Select all
lblanswer.text = 5+5
Notice that there are no quotations since we don't want the label to show 5+5 but we want it to show 10. We want it to do our calculation. Test this out and see if it works.

Try more exercises by using the following signs :

Adding = +
Subtraction = -
Multiplication = *
Division = /
Mod Division = \
Adding Powers = ^

Brackets can also be used as if your doing an equation such as :
Code: Select all
lblanswer = (5+5)^7
Moving on to Visibility :

You can make things invisible and visible to the user. It is also in the properties. Make a form with multiple picture boxes with pictures in them. Have 3 buttons and Name them accordingly with the pictures.

For example :

btnfunnypic
btnsuperpic

picfunny
picsuper

Click the buttons and add this code within each one.
Code: Select all
picfunny.visible = true
picsuper.visible = false
piclol.visible = false
What this does is takes the pictures we named picfunny, picsuper and piclol and make them visible or not. When this button is pressed we want only 1 visible and rest go invisible and to insure this, we added the visibility for the rest to false.

Now double click your form itself. It should open the coding for when the form loads. Put this code :
Code: Select all
picfunny.visible = false
picsuper.visible = false
piclol.visible = false
This is to insure that all pictures are invisible when your program loads so that it only shows when your click the buttons.

Adjust your button's codes accordingly to your own names and what you want it to set to. Instead of buttons you can also use radio buttons, but put them in a group box so it automatically deselects the radio button when you select another, otherwise you'll have to code more. REMEMBER PROGRAMMERS ARE LAZY!

Next is commenting. Commenting is used for many things, to explain your code when it gets complex and to provide help for another person as well as other things which i cannot recall at the moment.

a comment can be placed anywhere, in between code, beside it, above it.

TO comment just add a single ' before your message and example :
Code: Select all
'I am the best
Nothing more. Just that and your good to go.

Next time on Z TUT...VARIABLEEEESSS! fight;
Last edited by zulfikar on Thu Mar 22, 2012 10:49 pm, edited 3 times in total.
Image
User avatar
zulfikar
Member
Member
Posts: 30
Joined: Fri Aug 19, 2011 4:22 am

RESERVED
Image
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Ive bookmarked it and will check it out when you finish..beginner tutorials are always good cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Good for only beginners, though. I always appreciate tutorials. (+rep)
Image
User avatar
zulfikar
Member
Member
Posts: 30
Joined: Fri Aug 19, 2011 4:22 am

after i finish beginner's stuff i will add sum intermediate stuff too. I am personally not advanced, in fact i am learning too. No advance stuff will come from me, srry guys. The way i learned the basics was trial and error. Not everything is handed down in tutorials.

Thanks to you guys, this is my first tutorial hope its up to standard, if there's anything you wish to add or explained further or anything just msg me or reply here.

Tutorial will hopefully be added once everyday or every other day. Kinda busy with multiple tests atm.
Image
User avatar
zulfikar
Member
Member
Posts: 30
Joined: Fri Aug 19, 2011 4:22 am

COULD SOMEONE PLEASE DELETE THIS.
Image
8 posts Page 1 of 1
Return to “Tutorials”