VB设置一个10秒钟后才能按的按钮
发布网友
发布时间:2024-01-12 22:49
我来回答
共3个回答
热心网友
时间:2024-01-15 03:17
'添加窗体Form1,按钮Command1,然后添加如下代码:
Private Sub Form_Load()
Dim starttm$
Me.Show
Command1.Enabled = False
starttm = Timer
Do
DoEvents
If Timer - starttm >= 10 Then Exit Do
Loop
Command1.Enabled = True
End Sub
热心网友
时间:2024-01-15 03:18
Dim i As Integer
Private Sub form_load()
Timer1.Interval = 1000
i = 10
Command1.Enabled = False
Command1.Caption = i
Timer1.Enabled = True
End Sub
Private Sub timer1_timer()
i = i - 1
Command1.Caption = i
If i <= 0 Then
Command1.Enabled = True
Command1.Caption = "确定"
Timer1.Enabled = False
End If
End Sub
热心网友
时间:2024-01-15 03:18
Option Explicit
Dim sum As Integer
Private Sub Form_Load()
sum = 10
Command1.Caption = sum
Timer1.Interval = 1000
Timer1.Enabled = True
Command1.Enabled = False
End Sub
Private Sub Timer1_Timer()
sum = sum - 1
Command1.Caption = sum
If sum = 0 Then
Command1.Enabled = True
Command1.Caption = "确定"
Timer1.Enabled = False
End If
End Sub