注册 登录
编程论坛 VB6论坛

高手请指教,利用timer控件如何实现定时?列如想让下列程序运行3分钟,该家什么代码?

liu0033546 发布于 2013-04-16 22:36, 604 次点击
Private Sub Timer1_Timer()
m = 0
For i = 1 To 10000
x = Rnd
y = Rnd

If x ^ 2 + y ^ 2 < 1 Then
m = m + 1
End If
Next i
p = 4 * m / 10000

n = (m / 10000) - (m / 10000) ^ 2

Text1.Text = Text1.Text & p & vbCrLf
Text2.Text = Text2.Text & n & vbCrLf
Open "c:\131.txt" For Output As #1
Print #1, Text1.Text
Close #1

Open "c:\132.txt" For Output As #2
Print #2, Text2.Text
Close #2


End Sub
5 回复
#2
wube2013-04-17 03:50
form_load()
    timer1.I???=(1000*60*3)
    timer1.E???=false
end sub

.....
.....
timer1.E???=true
#3
liu00335462013-04-17 18:17
回复 2楼 wube
没有用哦
#4
Artless2013-04-17 20:04
想让程序运行3分钟

do...loop检测时间
#5
liu00335462013-04-17 20:12
回复 4楼 Artless
能具体写下代码吗,高手
#6
zhengang10262013-04-19 08:37
t = Timer
Do Until Timer - t = 180'延期3分钟
  '在此加入要运行的程序段
Loop

[ 本帖最后由 zhengang1026 于 2013-4-19 09:26 编辑 ]
1