Site hosted by Angelfire.com: Build your free website today!

Date and Time

 

         Okay, this program is a little harder, but not by much! It’s nice and easy, you can use either of the captions in any other program that you make to display you’re computer’s date and the time, hence the name!

 

1.)   Open VB 5.0

I’m sure that this is the last time that I’ll need to tell you what to open up!

 

2.)   Open the Standard EXE when prompted

This, again with the – this is regular procedure and I won’t need to tell you again.

 

3.)   On the form make a label

You will want to put the label along the top, long, but not too wide. Also, under the ‘Caption’ in ‘Properties’ you want to make sure that there are no words so that the label is clear.

 

4.)   Under the label you want to place two command buttons

These two command buttons will be named ‘Date’ and ‘Time’ respectively

 

5.)   Double click the ‘Date’ button and the code window will appear.

The code that you want to place in the command will be:

 

Private Sub Command1_Click()

    Label1.Caption = Date

End Sub

 

                  After this has been typed in you can close the window, you don’t need to save, it will happen by itself.

 

6.)   Double click on the ‘Time’ button and the code window for this will appear.

The code that goes in this window is not very different:

 

Private Sub Command1_Click()

    Label1.Caption = Time

End Sub

After this has been typed you can again close the window.

 

         To play this program you just do the same with the other. If there are errors it will be highlighted in yellow or red. If there are errors it is most likely that you spelled something wrong and you must find it before the program will work.

 

         If the program works: Good Job!!

Back

Home

Next Exercise