這不是VB的問題,而是windows系統(tǒng)規(guī)定的,所有標(biāo)準(zhǔn)窗口在拖動(dòng)時(shí)都是暫停的(專業(yè)術(shù)語叫“掛起”)。這是必要的,試想一下,如果在拖動(dòng)的過程中,窗口程序卻恰巧要移動(dòng)窗口,這時(shí)候是你的鼠標(biāo)說了算呢還是程序說了算,窗口要選擇聽誰的呢?
創(chuàng)新互聯(lián)建站主營普洱網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都app軟件開發(fā)公司,普洱h5成都小程序開發(fā)搭建,普洱網(wǎng)站營銷推廣歡迎普洱等地區(qū)企業(yè)咨詢
Public?Class?Form1
Inherits?System.Windows.Forms.Form
Dim?t?As?System.DateTime
Dim?c?As?Integer
Private?Sub?Button1_Click(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.Click
Try
c?=?TextBox1.Text
If?Timer1.Enabled?Then
Timer1.Stop()
Else
t?=?Now.AddHours(c)
Timer1.Start()
End?If
Catch?ex?As?Exception
MsgBox("")
End?Try
End?Sub
Private?Sub?Timer1_Tick(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?Timer1.Tick
Dim?d?As?TimeSpan?=?t.Subtract(Now)
Label1.Text?=?d.Hours??"小時(shí)"??d.Minutes??"分鐘"??d.Seconds??"秒"
End?Sub
End?Class
用Timer控件吧,設(shè)置1秒執(zhí)行1次。然后直接在Timer中寫代碼,將全全局的值來
減減1,如果值為0,則停止Timer
跳出提示框
以下示例:
int
Tatal
=
100;
Timer.Inveral
=
1000;
Timer_()
{
if
(
Tatal
==
0)
{
MessageBox.Show("完成!");
Timer.Stop();
}
else
{
Tatal
--;
}
}
加一個(gè)計(jì)時(shí)器控件Timer1
代碼如下:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Timer1.Interval = 15000
Timer1.Start()
MessageBox.Show("程序?qū)⒃?5s后關(guān)閉.")
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Dispose()
End Sub
在暫停按鈕的Click事件中設(shè)置:Timer1.Enable=False
在繼續(xù)按鈕的Click事件中設(shè)置:Timer1.Enable=True