Results 1 to 40 of 75

Thread: Dopey's Visual Basic 6.0 Tutorial Beginners Level 1

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    109

    Dopey's Visual Basic 6.0 Tutorial Beginners Level 1

    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.

    www.gamemaker.nl



    B. Resources and Source Code

    * http://www.devshed.com
    * http://www.vbcode.com (source code)
    * http://www.programmingtutorials.com
    * http://www.programmersheaven.com
    * http://www.pscode.com
    * http://rookscape.com/vbgaming/ (physics related programming stuff, good for making games with vb 6.0)

    Okay, now the coding part.

    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
    ALright, remember, + = add, - = subtract, *=multiply, and /=divide

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width