Okay. Lets get this straight. You want to be a programmer when you grow up right? "Right". Well, you have to learn to make decent programs. It takes time to learn a programming language, and more time to master it. You can't learn a programming language in one day and know how to make a advance game or application.
Programming.
A. Where to Start
Rome wasn't built in a day...
Programming is something that takes time to learn and even more time to master. You can't expect to read one book or take one class and start writing serious applications or games.
You have two options for learning programming:
A) Start in the shallow pool and move to the deep pool later on.
B) Go straight to the deep pool and try to hold yourself up using flotation devices.
I have friends that have tried starting out with programming languages such as Pascal/Turbo Pascal, Delphi, and Java and transitioned to C++ and Visual Basic. I found this way of learning to be a waste of time, considering I knew where I wanted to be before I started learning programming. So, I started out with visual basic.
If you are bad at organization and logic, you might want to try a higher level language such as Delphi before attempting to tackle C++. Delphi and C++ are structurally similar, so you will get the hang of C++ if you spent time learning Delphi.
In the event that you choose to take this route, I recommend downloading Game Maker. Game Maker is basically a development kit for people who are at entry level and want to learn the fundamentals of game creation. It was written in Delphi and includes its own scripting language in addition to using Delphi.
So what would a beginner like to make? Lets start with a classic Hello World application.
Code:
Command1_Button
MsgBox ("Hello World")
End Sub
This code means if you press the button you created, it will pop up the message "Hello World!". Remember, if you want to make a message always USE THE PARENTHESIS! If you get into a habit of not using the parenthesis, it will hurt you in the future! And remember, anything that is in parenthesis will be the text the your program will make. So if you put
Code:
Print "How are you?"
In a button, when you press the button it will make the text "How are you" at 00 xy axis. But heres another thing.
There are many methods to do this, heres another one.
Code:
A = "How are you?"
Print A
This can be another method, its both the same thing. Now, moving onto numbers. Heres the tricky part (for beginners).
NEVER DO THIS. ALOT OF PEOPLE MAKE BIG MISTAKES JUST BY MISTAKING THESE.
Code:
A = "5"
Print "A"
Guess what this code does? Okay so you want it to print the number 5 right? But instead it prints A because like i said, anything in quotes "" will be printed. It doesn't matter if you put "5" because you put "A" also, and you told it to print "A" instead of 5. To fix this error, what do you think we should do?
Code:
A = "5"
Print A
If you were thinking about getting rid of the quotes "" around A, you're right. Now the program will print 5 instead of A.
Alright now that you got a little better, lets move on.
More Advance Stuff
Now we're going to make a calculator. What kind? Add, Subtract, Multiply, and Divide.
Coding this calculator will make a big difference for you, in the future.
Code:
Private Sub Command1_Click()
//to add
Dim a As Integer
Dim b As Integer
a = Text1.Text
b = Text2.Text
Label4.Caption = Text1.Text + Text2.Text
//to subtract
Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
a = Text1.Text
b = Text2.Text
Label4.Caption = Text1.Text - Text2.Text
//to multiply
Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
a = Text1.Text
b = Text2.Text
Label4.Caption = Text1.Text * Text2.Text
//to divide
Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
a = Text1.Text
b = Text2.Text
Label4.Caption = Text1.Text / Text2.Text
End Sub
So take a look at the code above. I made 1 button, 8 textboxes, and 4 labels. The button is the most important, it is used to calculate. The button contains the most code.
So the label4.caption is where the answer will be printed. Text1.Text and Text2.Text are important too, its where you put the 2 values to add/subtract/multiply/divide.
So if Text1.Text + Text2.Text, those 2 values are added
if Text1.Text - Text2.Text, those 2 values are subtracted
if Text1.Text * Text2.Text, those 2 values are multiplied
if Text2.Text / Text2.Text, those 2 values are divided.
Thank you for your time reading this, please be successful for whatever you do, you're brain is the most important part, use it or lose it. You need a brain to make good programs, and i also alot of patience. May your wishes come true, and again, be successful in life. I hope this tutorial will wipe out some questions.
-DopeyGuy123
This tutorial was created by DopeyGuy123
Last edited by DopeyGuy123; Mar 24th, 2005 at 08:15 PM.
A timer is kind of advance...well its your opinion. In my opinion, a form and command button is the easiest...those were the first things i knew when i was a beginner at programming...
This thread is sooooo gonna be moved to the CodeBank - Visual Basic 6 (and before) once MartinLiss or any moderators/administrators see this
Timers are good for beginners to learn loops and stuff for games, but the fact of the matter is that Timers are slow, inaccurate, inconsistant, and get worse when you use more of them. Learned that the hard way back in the day when I was hooked on them using them in my games. C++, C#, Java, Delphi, and all those other languages don't have Timers. They use Do loops and While loops, which should be used in VB rather than Timers. If programmed right, you can have a real time managed loop going for your game or application.
C++, C#, Java, Delphi, and all those other languages don't have Timers. They use Do loops and While loops, which should be used in VB rather than Timers. If programmed right, you can have a real time managed loop going for your game or application.
What???? I use timers in C++ and Delphi all the time.... Do loops for timing? Yeah I used that back in the '80s . But I agree that the VB timer is not the best timer available on most system now days. Most computers of today have multimedia timers built into their hardware.
Well, may i ask..How do you tell a loop how fast to go? Is it possible?Like you can set the interval on a timer..
Well you can check the time in a loop and do stuff after a specific time has expired. A common function is the GetTickCount (which is a timer function btw, but it doesn't raise any events or have any callbacks). The fact that GetTickCount works means that Windows itself has timers running all the time , and last time I looked Windows wasn't written in VB, LOL.
In my sample project a couple posts above, I uses the QueryPerformanceCounter and QueryPerformanceFrequency API's which is 1 ms accurate. GetTickCount is 10 ms accurate. So those other 2 apis are better.
In my sample project a couple posts above, I uses the QueryPerformanceCounter and QueryPerformanceFrequency API's which is 1 ms accurate. GetTickCount is 10 ms accurate. So those other 2 apis are better.
Yeah I know that. I've already stated that Multimedia timers are more accurate, but you can't say that the QueryPerformance functions are 1 ms accurate because it depends on the hardware of the computer.
What it all comes down to though is how accurate you really need to be. If you only need to run a specific code once every second or so or maybe 2 or 3 times each second the VB timer will do the job. If you want a specific task to run every hour or maybe just once per day the SetTimer API function would probably be the best choice since you can pass a Long as the interval. But if you really are in demand of a high resolution timer you should of course use one (if one is available on your system).
This thread is sooooo gonna be moved to the CodeBank - Visual Basic 6 (and before) once MartinLiss or any moderators/administrators see this
Timers are good for beginners to learn loops and stuff for games, but the fact of the matter is that Timers are slow, inaccurate, inconsistant, and get worse when you use more of them. Learned that the hard way back in the day when I was hooked on them using them in my games. C++, C#, Java, Delphi, and all those other languages don't have Timers. They use Do loops and While loops, which should be used in VB rather than Timers. If programmed right, you can have a real time managed loop going for your game or application.
Why isn't this moved yet? I want beginners to read this, so they can learn and at least have some knowledge of basic programming. I am not saying im a ub3r pro programmer for vb 6.0, im just saying i want to help beginners, give them knowledge. Oh yeah, Jacob Roman, why did u say quote
"This thread is sooooo gonna be moved to the CodeBank - Visual Basic 6 (and before) once MartinLiss or any moderators/administrators see this"
I doesn't have topics at all. It has descriptions of projects, some explanations, and a zip file of the project. It includes SOURCE CODE. Hence, it's called the CodeBank.
This is a thread that describes a few things that you know, that can be searched in the future if anyone wants to know the answers to some of the same questions.
I doesn't have topics at all. It has descriptions of projects, some explanations, and a zip file of the project. It includes SOURCE CODE. Hence, it's called the CodeBank.
This is a thread that describes a few things that you know, that can be searched in the future if anyone wants to know the answers to some of the same questions.
alright....if you have some friends that just started vb, tell them to take a look at my tutorial. Or you could just receive help from a book, or the internet of coruse.
If I ever write a book, I'll make it teach everyone all of the controls and how to use them and their properties and stuff, the command button comes first then a timer then a textbox then a label. and i'll teach them about msgboxes and inputboxes and how to detect what the input is. You should add that
If I ever write a book, I'll make it teach everyone all of the controls and how to use them and their properties and stuff, the command button comes first then a timer then a textbox then a label. and i'll teach them about msgboxes and inputboxes and how to detect what the input is. You should add that
this is beginners level 1, im not making it that hard.
The reason why I said that this would get moved in the CodeBank is because I had like maybe a couple tutorials of my own moved there. Like the thread "DoEvents is slow!!! Here are faster methods" It was like a tutorial as well as info, but it got moved anyways. Probably because I uploaded code projects in there. I assumed that all tutorials get moved there as well.
Note to XP users: I think I might have fixed this problem, but if you see only half the game with it cut off diagnally, I may have to get rid of the fade-in/fade-out effect.
Controls:
---------------
Arrow Keys - Moves ship
Space - Fire (hold down for autofire)
Numpad - Moves Camera
Mouse - Free looking camera
F12 - Snapshot
Esc - Exits the program after it fades out.
Last edited by Jacob Roman; Mar 26th, 2005 at 01:07 PM.
Note to XP users: I think I might have fixed this problem, but if you see only half the game with it cut off diagnally, I may have to get rid of the fade-in/fade-out effect.