📄 011301.htm
字号:
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>vb study</title><style>
<!--
td {font-size: 9pt}
A:link {text-decoration: none; color: #0033cc;font-size: 9pt}
A:visited {text-decoration: none; color: #0066CC;font-size: 9pt}
A:active {text-decoration: none; color: #ff0000; font-size: 9pt}
A:hover {text-decoration: underline; color: #000000;font-size: 9pt}
-->
</style>
</head>
<body>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="98%">
<tr>
<td width="100%"><a href="#">你的位置</a>:<a href="http://www.xxby.com" target="_blank">华生小屋</a>--<a href="#">VB学习</a>--<a href="#">基本控件</a></td>
</tr>
<tr>
<td width="100%">
<p align="center">时钟Timer对象</td>
</tr>
<tr>
<td width="100%"><br>
时钟对象TIMER的interval属性:确定每隔多少毫秒触发一次它的timer事件(Private sub timer1_timer()) <br>
如有一个定时器的例子,在属性窗口中先设置timer1的interval属性为60000(1分钟),设置enabled为true.代码为:<br>
Private Sub Command1_Click()<br>
If Text1.Text = "abcde" Then<br>
Timer1.Enabled = False --如果输入符合条件,就关闭定时器<br>
MsgBox ("welcome my sky")<br>
Else<br>
MsgBox ("i don't know you")<br>
End If<br>
End Sub<br>
<br>
Private Sub Timer1_Timer() --timer1的enabled属性为true,运行程序时即开始<br>
MsgBox ("你的时间已到了") 计时。<br>
End --超过1分钟后该事件触发,关闭程序。<br>
End Sub<br>
注:???当在后台运行计时器的事件时,可输入%号来暂停计时器事件的运行,按其他键继续。<br>
技巧一则:时钟控件timer对象的interval属性最大值为65535,充其量也就是1分钟多一点,而我想把时间间隔再扩大一些,如5分钟才执行一次,该怎么办?<br>
很简单:在timer1_timer()事件中设一个静态变量,每累积到一定值时才去执行主要的代码,如下:<br>
Private Sub Timer1_Timer()<br>
Static lxn As Integer<br>
lxn = lxn + 1<br>
If lxn = 10 Then<br>
' 事件过程<br>
lxn = 0<br>
End If<br>
End Sub
<p align="center">
<br>
< <a href="011201.htm">上一页</a>--<a href="http://www.xxby.com" target="_blank">华生小屋</a>--<a href="011401.htm">下一页</a>
><br>
</p>
</td>
</tr>
</table>
</center>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -