Video Tutorial-Visual Basic and Explanation || Create a Stopwatch

in #utopian-io7 years ago (edited)

###Video Tutorial-Visual Basic || Create a Stopwatch


Visual Basic || Create a Stopwatch

Now we try to make small programs again, after yesterday for the program that make forehead shrink.

1.First, As always, we create a form like below.

v1.jpg

Then Command2 in the stack in command 1, as below

v2.jpg

  1. We start to set its properties
    Label1
    Name: LblDate
    Caption: Date

Label2
Name: TimeLbl
Caption: Time

Command1
Name: CmdStart
Caption: Start
Style: true (to give color to command button, color as you like)

Command1
Name: CmdStop
Caption: Stop

Timer1
interval: 1000 (this per second)

So the form will change like this:

v3.jpg

  1. Now we start doing pengkodingan
    First we assume after the program on the run, immediately display the current date, the Start button and the new time appears if the start button on click. While the Stop Button does not appear.
    Private Sub Form_Load()
    CmdStart.Visible = True
    CmdStop.Visible = False
    LblTanggal.Caption = Format(Date, "dddd,dd-mmmm-yyyy")
    'dddd=hari
    'dd=tanggal
    'mmmm=bulan dalam bentuk tulisan, jika cuma mm =bulannya dalam bentuk angka
    'yyyy=tahun

Timer1.Enabled = False
'timer belum berjalan atau di nonaktifkan
End Sub

Now we set the timer
Private Sub Timer1_Timer()
LblWaktu.Caption = Format(Now, "hh:mm:ss")
'jam, menit dan detik yang sekarang
'hh=jam
'mm=menit
'ss=detik
End Sub

When we click Start then the time will run and Stop button Shown while the Start button is lost.
Private Sub CmdStart_Click()
Timer1.Enabled = True
CmdStop.Visible = True
CmdStart.Visible = False
End Sub

When we click Start then the time will run and Stop button Show while the Start button is lost. Then when we click Stop. The timer is on non-activate, and the stop tomlo is hidden while the start button is displayed.
Private Sub CmdStop_Click()
Timer1.Enabled = False
CmdStop.Visible = False
CmdStart.Visible = True
End Sub

Program after the run

v4.jpg

v5.jpg

Thank You Very Much



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Hai friend follow me upvote, thanks

Your contribution cannot be approved because it does not follow the Utopian Rules, and is considered as plagiarism. Plagiarism is not allowed on Utopian, and posts that engage in plagiarism will be flagged and hidden forever.

That video isn't yours, it's from someone else that made it in 2009 and the repository is wrong.

You can contact us on Discord.
[utopian-moderator]