这不是VB的问题,而是windows系统规定的,所有标准窗口在拖动时都是暂停的(专业术语叫“挂起”)。这是必要的,试想一下,如果在拖动的过程中,窗口程序却恰巧要移动窗口,这时候是你的鼠标说了算呢还是程序说了算,窗口要选择听谁的呢?
创新互联建站主营普洱网站建设的网络公司,主营网站建设方案,成都app软件开发公司,普洱h5成都小程序开发搭建,普洱网站营销推广欢迎普洱等地区企业咨询
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 "小时" d.Minutes "分钟" d.Seconds "秒"
End Sub
End Class
用Timer控件吧,设置1秒执行1次。然后直接在Timer中写代码,将全全局的值来
减减1,如果值为0,则停止Timer
跳出提示框
以下示例:
int
Tatal
=
100;
Timer.Inveral
=
1000;
Timer_()
{
if
(
Tatal
==
0)
{
MessageBox.Show("完成!");
Timer.Stop();
}
else
{
Tatal
--;
}
}
加一个计时器控件Timer1
代码如下:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Timer1.Interval = 15000
Timer1.Start()
MessageBox.Show("程序将在15s后关闭.")
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Dispose()
End Sub
在暂停按钮的Click事件中设置:Timer1.Enable=False
在继续按钮的Click事件中设置:Timer1.Enable=True