Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to make digital clock in VB programming
How to make digital clock in VB programming
1. Add a label Control and name it Label.

2. Add a timer control and name it timer 1.

3. Set the interval attribute of "timer 1" to 1000.

Code used:

Dim? An hour? As? Integer? hour

Dim? Min? As? Integer? minute

Dim? Sec? As? Integer? second

Private? Sub? Form_Load()

An hour? =? 0

Min? =? 0

Sec? =? 0

Label 1。 Title? =? "00? :? 00? :? 00"

End? submarine

Private? Sub? Timer 1 _ Timer ()

Dim? strHour? As? line

Dim? strMin? As? line

Dim? strSec? As? line

Sec? =? Sec? +? 1

What if? Sec? & gt=? 60? then

Sec? =? 0

Min? =? Min? +? 1

What if? Min? & gt=? 60? then

Min? =? 0

An hour? =? An hour? +? 1

What if? An hour? & gt=? 24? then

An hour? =? 0

End? if

End? if

End? if

What if? An hour? & lt? 10? then

strHour? =? "0"? & amp? hour

other

strHour? =? hour

End? if

What if? Min? & lt? 10? then

strMin? =? "0"? & amp? Fujian dialect

other

strMin? =? Fujian dialect

End? if

What if? Sec? & lt? 10? then

strSec? =? "0"? & amp? One second

other

strSec? =? One second

End? if

Label 1。 Title? =? strHour? & amp? "? :?" ? & amp? strMin? & amp? "? :?" ? & amp? strSec

End? submarine