thuy linh
Trả lời 15 năm trước
Rất đơn gian, bạn tạo một form trong đó có các controler sau:
Text1
Text2
Command1
Timer1
nhấn đúp chuột lên bất cứ controller nào, sau đó copy và paste phần mã sau đây vào, đè lên tất cả những gì bạn thấy trong phần code:
Dim i As Long
Private Sub Command1_Click()
'set the countdown to change every one second.
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
'every one second text2.text will be one digit less than that of the text1.text
Text2.Text = Str(Val(Text1.Text) - i)
i = i + 1 'stop the countdown when text2.text reaches 0
If Trim(Text2.Text) = "0" Then
Timer1.Interval = 0
End If
End Sub.