PDA

View Full Version : [vb6] Tutorial 1


Darkchild
06-09-2007, 10:29 PM
Darkchild's Visual Basic tutorial lesson 1
----------------------------------------------------------------------------------------------------------------------


First thing in programming is...you have to know variables!

Q: What are variables? Simple!

For example...Have you ever used letters in math (like X or Y)? X and Y are variables, they can hold ANY number, but it is you or the program who have to give them the number to hold...Sub Question : Where is this data stored in?

Simple! It's stored in your Ram!

Now, there are lots and lots of types of variables, but for now, I'm gonna teach you the simpler ones that you will need:
Integer
String
Boolean
ByteNow what is the difference between these variables? Simple!
Integer uses whole numbers (you can't use 0.01 as an integer value)
String uses Numbers, letters, special characters like (@£§€)
Boolean uses only two values, true and false
Byte uses numbers from 0 to 255Simple? Good!:biggrin:

Now how to declare these variables (because, they aren't made by themselves!)


Dim name_of_variable as type
Where "name_of_variable" is the name of the variable you are declaringSub Question : Can I put ANY characters in my variables?

Not all... for example you CANNOT use:
Numbers at the beginning of the variable's name
Special Characters
Names of variables that were already declaredat the beginning of the variable's name or else you will have a huge error!

Where Type, you write ONE those 4 types of variables that I told you about.
You can have pretty much as many variables you want, and any amount of variables of the same type you want.

Now How to declare various variables without having to write "DIM" in another line


Dim var1, var2, var3 as integer
I think this is self explanatory XD
More lessons later! Post your questions here if you have any!

You can download Visual Basic here (http://msdn.microsoft.com/vstudio/express/) (although it is .NET, the basics would be...the same).

bwalker
06-10-2007, 10:20 PM
so "Dim var1, var2, var3 as byte" declares those thre variables as byte variable or do i have this all wrong lol

Darkchild
06-10-2007, 10:34 PM
yes, that declares them all as Bytes
it is correct =)

bwalker
06-11-2007, 12:47 AM
sweet then your tut 1 is a sucess good job i look foward to more

Darkchild
06-14-2007, 11:01 PM
next tuto I'll show you the IDE and how to work with it, for future tutorials :)

roe-ur-boat
08-09-2007, 02:38 PM
What do I need to start developing in VB6

Darkchild
08-09-2007, 08:40 PM
You need Visual Studio 6 xD

roe-ur-boat
08-09-2007, 08:41 PM
ok, you told me the name before, I just forgot

Darkchild
08-10-2007, 12:17 AM
no prob, but..WHERE to get it...I cannot say :P

Junit
08-10-2007, 04:30 AM
The microsoft store xD

roe-ur-boat
08-10-2007, 10:15 PM
Ok then . Whens he next tut :P

Darkchild
08-11-2007, 12:39 AM
when 3+ people ask me to do it

Cheezeball99
08-11-2007, 12:41 AM
Me, bwalker and roe-ur-boat. Done- DO IT.:biggrin:

EDIT: Well, there's five now. Basically everyone- I don't see what choice you have, there, DC.

Junit
08-11-2007, 02:03 AM
Me too LOL I wanna learn too :P

Acerthief
08-11-2007, 02:20 AM
make it 4!!
i have this crappy VB6 book, totally useless, so i'm counting on you to sir!
Private Acer to your orders!

Darkchild
08-11-2007, 06:03 AM
ok then, it's 6 AM here, when I wake up (cuz I'm going to bed) I'll make the second one =)

roe-ur-boat
08-11-2007, 01:53 PM
Thanks dude. YOU DA MAN!! xD

EvilSeph
11-06-2007, 05:00 AM
Nice work. Love the formatting and the clearly articulated information.

Corrections and comments in line (in red):
Darkchild's Visual Basic tutorial lesson 1
----------------------------------------------------------------------------------------------------------------------


First thing in programming is...you have to know variables!

I'm going to have to disagree here but...it isn't such a big deal.

Q: What are variables? Simple!

For example...Have you ever used letters in math (like X or Y)? X and Y are variables, they can hold ANY number, but it is you or the program who have to give them the number to hold...Sub Question : Where is this data stored in?

It might be wise to clarify that Variables don't have to only hold numbers.

Simple! It's stored in your Ram!

Not always. Though this tutorial is a beginner one, I'm not too sure what your target audience is.

Now, there are lots and lots of types of variables, but for now, I'm gonna teach you the simpler ones that you will need:
Integer
String
Boolean
ByteNow what is the difference between these variables? Simple!
Integer uses whole numbers (you can't use 0.01 as an integer value)
String uses Numbers, letters, special characters like (@£§€)
Boolean uses only two values, true and false
Byte uses numbers from 0 to 255Simple? Good!:biggrin:

An important point about Integers is that they can be both negative and positive.

You may also want to cover variants as they are useful and powerful when used properly and something a beginner should definitely know of.

Now how to declare these variables (because, they aren't made by themselves!)

Yes they are. Unless Option Explicit is used, variables need not be declared.

On that note, the usage of Option Explicit should be one of the first things taught and something you should go into detail about or we'll be creating programmers with poor styles, habits and mindsets.


Dim name_of_variable as type
Where "name_of_variable" is the name of the variable you are declaringSub Question : Can I put ANY characters in my variables?

Not all... for example you CANNOT use:
Numbers at the beginning of the variable's name
Special Characters
Names of variables that were already declaredat the beginning of the variable's name or else you will have a huge error!

You also cannot use special keywords reserved by Visual Basic. I believe it is important to outline this and what keywords are.

Where Type, you write ONE those 4 types of variables that I told you about.
You can have pretty much as many variables you want, and any amount of variables of the same type you want.

Now How to declare various variables without having to write "DIM" in another line


Dim var1, var2, var3 as integer
I think this is self explanatory XD

Though this practise may work, it is bad and incorrect. Declaring multiple variables in one line declares any variable after the first , as a variant.

More lessons later! Post your questions here if you have any!

Keep it up. I await subsequent lessons from you and hope my constructive criticism helps you improve your teaching and helps you with your learning too.

You might want to include a download to Visual basic in your tutorial. I've provided a url below for it.

You can download Visual Basic here (http://msdn.microsoft.com/vstudio/express/).

Darkchild
11-06-2007, 05:52 PM
1st. Thanks for correcting :)
2nd. This is for Visual Basic 6, not express nor .net ;)
3rd. Care to edit my first post? XD I'm lazy ;__;

EvilSeph
11-06-2007, 10:45 PM
I understand, but we removed the download for just VB6 alone as .NET is the direction we wish everything should go.

Edit your first post to include the link?

Darkchild
11-07-2007, 08:58 AM
if it doesn't have VB6...Sorry :X but you could put up a link with MiniVB6 that has all the basics :X