Results 1 to 2 of 2

Thread: Visual Basic ... A Basic Tutorial (EX2)

  1. #1
    Junior Member
    Join Date
    Sep 2002

    Visual Basic ... A Basic Tutorial (EX2)

    This is the second exercise in my attempt at a tutorial! Please dont flame me much i trying my hardest

    Exercise 2 : Hello Project

    Remember : Each New Project Should Be Saved In A New Folder

    1) Create a new folder in which to save this project, e.g c:\Hello

    2) On a new form, draw one label and three command buttons and set the following properties:

    Command Button1:

    Name = cmdDisplay
    Caption = Display


    Name = cmdClear
    Caption = Clear
    Enabled = False

    Command Button3:

    Name = cmdExit
    Caption = Exit


    Name = lblMessage
    Caption = (leave Blank)
    Font Size = 14


    Name = frmGreetings
    Caption = Greetings!

    2) There are three events possible here:

    - the cmdDisplay button is clicked
    - the cmdClear button is clicked
    - the cmdExit button is clicked

    so you must attach code to each button.

    When the Display button is clicked we want to:

    Display 'Hello Pat' in the label, lblMessage
    Make the clear button enabled (so user can click it)
    Make the Display button disabled (so user cant click it)

    so, attach this coding to the display button:

    Sub cmdDisplay_Click()

    lblMessage.Caption = "Hello Pat"
    cmdClear.Enabled = True
    cmdDisplay.Enabled = False

    End Sub

    3) Attach similar coding to the clear button, so that the following will happen when it is clicked:

    Display nothing in the label, lblMessage
    Make the Display button enabled (So user can click it)
    Make the clear button disabled (So user cant click it)

    Work this out for yourself :-P

    HINT: code it between

    Sub cmdClear_Click()

    End Sub

    4) Attach code to the exit button so that the program will end when this button is clicked:

    Sub cmdExit_Click()


    End Sub

    5) Run your program and see what it does

    6) Use save project as to save the project to the folder you created in step 1

  2. #2
    Senior Member
    Join Date
    Jun 2002
    Just a (humble) suggestion before you post another tutorial - it may be a better idea to compile these tutorials together and post them as a single, more comprehensive introduction to Visual Basic. You may find this brings you more success on this site over posting two or three tutorials on the same subject. Also, instead of stating that your English or grammar isn't any good, why not run a spell check and a grammar check on your tut before you post it?

    The content of the tutorials themselves is fine, these are just some ideas on their presentation.

    Good Luck


Posting Permissions

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