Darkchild
The Doctor
Ladies and gentleman, young ones and old ones!!
Here it is! the 3rd VB6 TUTORIAL!!!
Today we learn : CODE!
First of all!! the mother of all codes! The "hello world!"
Well, to begin start a "Standard EXE" project, after that he shows you a form, this is the form in which we are going to work!
double click the form!
(a new window should appear, and if you read my previous tutorial you will know that it is the code window)
In there you should see something like:
Now to explain what these lines mean!
"public sub form_load()" is the "header" for the set of code that will occur WHEN the form loads (Form_load, got it? no? well this part of the header is in this syntax : "component_event(parameters)" simple, no? )
now, you can put it in private instead of public (by replacing "public" for "private" although I don't recommend it >.< do this on modules and stuff not on forms! (again just a suggestion))
and now the "end sub" this is the finish of the set of code that will be executed when the event on the header starts
now! for the "hello world" program!
As you may know the code above, the header and the finish must NOT be deleted if you are working to put code into that event, they both must stay intact!
ok! this is the first command you will learn!
MSGBOX
syntax:
msgbox text as string, messagestyle as vbstyle, title as string
Here's an example:
(remember this has to be between the "public sub" and the "end sub" of the event you want it to occur in!
and as you can see he displayed an error! saying "Hello world!" and has a title named "HELLO WORLD PROGRAM!" and has that little "i" on the left (information warning!)
here's a trick for this msgbox!
Crowd : YOU FORGOT SOME PARAMETERS!!!!
err... no I didn't! Msgbox only needs one (the text), the other ones are optional, if you don't tell him the error style he won't put any icon on the left of the warning!
Crowd : AND ABOUT THAT PLUS!! DON'T YOU MEAN "&"??
No, VBCRLF is like "/n" in C++ so between the lines you have to put it as a plus, "&" is for joining strings!
Now that these questions have been cleared...
to explain the line code!
Notice the " + VBCRLF + " between every set of strings? like I said above it's like pressing Enter on word or... "/n" in c++ or "<br>" in html
Note : USE VBCRLF ON MSGBOX ONLY!
[/MSGBOX]:laugh: (I made a funny!!)
Crowd : Is form_load all we can have as events?
Hell no! You have loads of them, PER COMPONENT!
look at the image below:
that list on the right is all the events you can have, and on the right the components, this will be very helpful to the new ones in the programming language!
By choosing a component and then an event, VB will automatically create the header and the end of the header for the component and event chosen, then all you have to do is dump the code in it
Very simple am I correct?
now...create a label on the form!
and in the code put :
where label1 is the name of the label you've put (by default, it's label1)
.caption is a propriety, in which is the text to display in the label
"TEXT IN LABEL" Well...this is self explanatory
Well...This is all for today, toy around with other objects and start learning!
By the way, I'm accepting suggestions on about what to write for the next tuto so... post sum suggestions and comments
Darkchild..OUT!
Here it is! the 3rd VB6 TUTORIAL!!!
Today we learn : CODE!
First of all!! the mother of all codes! The "hello world!"
Well, to begin start a "Standard EXE" project, after that he shows you a form, this is the form in which we are going to work!
double click the form!
(a new window should appear, and if you read my previous tutorial you will know that it is the code window)
In there you should see something like:
Code:
Public sub Form_load ()
end sub
Now to explain what these lines mean!
"public sub form_load()" is the "header" for the set of code that will occur WHEN the form loads (Form_load, got it? no? well this part of the header is in this syntax : "component_event(parameters)" simple, no? )
now, you can put it in private instead of public (by replacing "public" for "private" although I don't recommend it >.< do this on modules and stuff not on forms! (again just a suggestion))
and now the "end sub" this is the finish of the set of code that will be executed when the event on the header starts
now! for the "hello world" program!
As you may know the code above, the header and the finish must NOT be deleted if you are working to put code into that event, they both must stay intact!
ok! this is the first command you will learn!
MSGBOX
syntax:
msgbox text as string, messagestyle as vbstyle, title as string
Here's an example:
Code:
Msgbox "Hello World!", vbinformation, "HELLO WORLD PROGRAM!"
(remember this has to be between the "public sub" and the "end sub" of the event you want it to occur in!
and as you can see he displayed an error! saying "Hello world!" and has a title named "HELLO WORLD PROGRAM!" and has that little "i" on the left (information warning!)
here's a trick for this msgbox!
Code:
msgbox "Line1" + vbcrlf + "line2" + vbcrlf + "line3"
Crowd : YOU FORGOT SOME PARAMETERS!!!!
err... no I didn't! Msgbox only needs one (the text), the other ones are optional, if you don't tell him the error style he won't put any icon on the left of the warning!
Crowd : AND ABOUT THAT PLUS!! DON'T YOU MEAN "&"??
No, VBCRLF is like "/n" in C++ so between the lines you have to put it as a plus, "&" is for joining strings!
Now that these questions have been cleared...
to explain the line code!
Notice the " + VBCRLF + " between every set of strings? like I said above it's like pressing Enter on word or... "/n" in c++ or "<br>" in html
Note : USE VBCRLF ON MSGBOX ONLY!
[/MSGBOX]:laugh: (I made a funny!!)
Crowd : Is form_load all we can have as events?
Hell no! You have loads of them, PER COMPONENT!
look at the image below:
that list on the right is all the events you can have, and on the right the components, this will be very helpful to the new ones in the programming language!
By choosing a component and then an event, VB will automatically create the header and the end of the header for the component and event chosen, then all you have to do is dump the code in it
Very simple am I correct?
now...create a label on the form!
and in the code put :
Code:
label1.caption = "TEXT IN LABEL!"
where label1 is the name of the label you've put (by default, it's label1)
.caption is a propriety, in which is the text to display in the label
"TEXT IN LABEL" Well...this is self explanatory
Well...This is all for today, toy around with other objects and start learning!
By the way, I'm accepting suggestions on about what to write for the next tuto so... post sum suggestions and comments
Darkchild..OUT!