Showing posts with label digital clock in visual basic 6. Show all posts
Showing posts with label digital clock in visual basic 6. Show all posts

Friday, May 30, 2014

Digital Clock in Visual Basic 6


Computers plays an important role in our day to day lives it can be used to process information that is useful in making good decisions whether in business or in our personal decisions. In this article I will show you how to make a simple Digital Clock using Microsoft Visual Basic 6.

This program will display the current time in your computer in digital format. Making this program is very easy because in Visual Basic 6 there are many controls that makes computer programming more easier to implement. I'm using a timer control in this program and label control to display the current time from our computer. 

If you wonder how the computer know the exact time very simple our computer is equip of a CMOS chip. CMOS means complimentary metal oxide semiconductor that stores the computer related instructions including the date and time of our computer. Even the computer is off but still the time and date is updated because it have a battery that connected in the computer motherboard.

I hope you find my program useful in learning how to  a programming using Microsoft Visual Basic 6.

Thank you very much until the next article.



Sample Output of Our Program


Program Listing

Private Sub Form_Load()
Label1.Caption = Format(Time, "h:mm:ss AM/PM")
Label1.Width = Me.Width
Label1.Height = Me.Height
Label1.Top = Me.Top
Label1.Left = Me.Left
End Sub

Private Sub Timer1_Timer()
Dim s As String
If InStr(Label1.Caption, ":") > 0 Then
    s = Replace(Label1.Caption, ":", " ", , , vbTextCompare)
    Label1.Caption = s
Else
   Label1.Caption = Format(Time, "h:mm:ss AM/PM")
End If
End Sub