关于VFP编程

来源:百度知道 编辑:UC知道 时间:2024/05/18 20:23:22
请教高手帮我写个计时程序,计时器从表单打开开始计时,而且在一个标签控件上显示时间过程,以00:00:00——00:30:00为例子,谢谢!
还有在一个表单的执行过程中能关闭所有正在运行的表单应该怎么写代码?请高手指教一二!

晕~自己就没讲清楚~你要的计时器是像秒表还是时钟,明显楼上的就把你的意思理解成物理时钟了~~~
如果是秒表的话:
form1_init
public p
p=0
this.label1.caption="00:00:00"
this.timer1.interval=1000

timer1_timer
p=p+1
m=mod(p,60)
f=int(mod(p,3600)/60)
s=int(p/3600)
cs=iif(s<10,”0”+str(s,1),str(s,2))
cf=iif(f<10,”0”+str(f,1),str(f,2))
cm=iif(m<10,”0”+str(m,1),str(m,2))
thisform.label1.caption=cs+”:”+cf+”:”+cm

这个是计时器,就是秒表.

显示当前时间:
给表单添加两个标签,和一个计时器.
在计时器的timer事件代码中输入:
thisform.label1.caption=alltrim(str(year(date())))+"年"+alltrim(str(month(date())))+"月"+alltrim(str(day(date())))+"日"
thisform.label2.caption=time()
关闭正在运行的表单用:thisform.release或release thisform
要关闭所有就用:close all吧

http://zhidao.baidu.com/question/42656808.html?si=3
查看这里

close all