怎么用VB6.0编一个倒计时程序

怎么用VB6.0编一个倒计时程序,第1张

楼上的代码这么长,还简单?

无语

我给你写了一个,这个才是真正的简单实用,呵呵!

加个TIMER控件

把Interval

属性调成

1000

毫秒

也就是

1秒

在加两个

TEXT

text1text=3

text2text=00

在加个按钮

开始倒计时

就行了

程序代码如下:

Private

Sub

Form_Load()

Timer1Enabled

=

False

End

Sub

Private

Sub

Timer1_Timer()

If

(Text2Text

<=

0)

Then

Text2Text

=

59

Text1Text

=

Text1Text

-

1

Else

Text2Text

=

Text2Text

-

1

End

If

End

Sub

Private

Sub

Command1_Click()

Timer1Enabled

=

True

End

Sub

如果有什么地方不懂,欢迎联系我!

回答会自动过滤缩进,需要按照上图调整语法缩进,下方是代码

import time

# 设置倒计时时间(单位:秒)

countdown_time = 20

# 开始循环

while countdown_time > 0:

# 打印当前倒计时时间

print(countdown_time)

# 等待 1 秒

timesleep(1)

# 倒计时时间减 1

countdown_time -= 1

# 倒计时结束

print("倒计时结束!")

对硬件的啊。

P2=0;

P1=display_code[display_data[i]];

P2=k;

k=k>>1;

不懂。

不过感觉问题不大。先把main里的i的上限从250改到216

在display()里做3个判断(可能会要做个全局变量,或者加个参数,记录当前是多少。)

判断是否是0,大于10,大于100

另外,站长团上有产品团购,便宜有保证

Dim Hours As Integer

Dim Minutes As Integer

Dim Seconds As Integer

Dim Time As Date

Private Sub Command2_Click()

Timer1Enabled = True

End Sub

Private Sub Command1_Click()

Number = InputBox("输入倒计时时间,以秒为单位", "输入框", "100")

Hours = Number / 3600

Minutes = (Number - Hours 3600) / 60

Seconds = (Number - Hours 3600 - Minutes 60)

Time = TimeSerial(Hours, Minutes, Seconds)

Label1Caption = Format$(Time, "hh") & ":" & Format$(Time, "nn" _

)& ":" & Format$(Time, "ss")

End Sub

Private Sub Form_Load()

Form1Top = (ScreenHeight - Form1Height) / 2

Form1Left = (ScreenWidth - Form1Width) / 2

Timer1Interval = 1000

Hours = 0

Minutes = 0

Seconds = 0

Time = 0

End Sub

Private Sub Timer1_Timer()

Timer1Enabled = False

If (Format$(Time, "hh") & ":" & Format$(Time, "nn") & ":" & Format$(Time, "ss")) <> "00:00:00" Then 'Counter to continue lo _op until 0

Time = DateAdd("s", -1, Time)

Label1Visible = False

Label1Caption = Format$(Time, "hh") & ":" & Format$(Time, "nn" _

) & ":" & Format$(Time, "ss")

Label1Visible = True

Timer1Enabled = True

Else

Timer1Enabled = False

Beep

Beep

End If

End Sub

'建Command1,Command2,timer1,label1 试试吧,响铃从耳机输出,

#include <reg52h>

#define uint unsigned int

#define uchar unsigned char

sbit dula=P2^6; //段选

sbit wela=P2^7; //位选

uchar shi,ge,num1,num2; //变量

uchar code table[]={0x3f,0x06,0x5b,0x4f, //共阴极字型码

0x66,0x6d,0x7d,0x07,

0x7f,0x6f,0x77,0x7c,

0x39,0x5e,0x79,0x71};

void delay(uint x) //延时子程序

{

uint i,j;

for(i=0;i<x;i++)

for(j=0;j<120;j++);

}

void init()

{

TMOD=0x01; //设置定时器0的工作方式

TH0=(65536-50000)/256; //装初值

TL0=(65536-50000)%256;

EA=1; //开总中断

ET0=1; //开定时器0中断

TR0=1; //启动定时器0

}

void display() //显示子程序

{

dula=1;

P0=table[ge]; //送段选数据

dula=0;

P0=0xff; //送位选数据前关闭所有显示

wela=1;

P0=0xfe; //送位选数据

wela=0;

delay(5); //延时

dula=1;

P0=table[shi];

dula=0;

P0=0xff;

wela=1;

P0=0xfd;

wela=0;

delay(5);

}

void main()

{

init();

while(1)

{

display();

}

}

void timer() interrupt 1

{

TH0=(65536-50000)/256; //重装初值

TL0=(65536-50000)%256;

num1++;

if(num1==20) //到了20次,1秒时间到

{

num1=0; //清0重新计数

num2++;

if(num2==60)

num2=0;

P1=0x00;

delay(500);

P1=0xff;

shi=num2/10; //把一个2位数分离后分别送数码管显示

ge=num2%10; //十位和个位

}

}

试了的,可以放心,采纳吧!

软件如下:

可以用软件时间规划局。时间规划局下载是一款提醒事项与时间管理的手机应用,时间规划局app苹果版下载支持农历显示,支持百分比形式,时间规划局ios下载安装支持更改百分比的精确度,支持分类管理以及支持自定义小组件背景等功能。

简介:

软件(中国大陆及香港用语,台湾称作软体,英文:software)是一系列按照特定顺序组织的计算机数据和指令的集合。

一般来讲软件被划分为系统软件、应用软件和介于这两者之间的中间件。软件并不只是包括可以在计算机(这里的计算机是指广义的计算机)上运行的电脑程序,与这些电脑程序相关的文档一般也被认为是软件的一部分。简单的说软件就是程序加文档的集合体。

另也泛指社会结构中的管理系统、思想意识形态、思想政治觉悟、法律法规等等。

3个标签,2个按钮,1个计时器控件

Private Sub Command1_Click() '开始/暂停

If Timer1Enabled = True Then

Timer1Enabled = False

Else

Timer1Enabled = True

End If

End Sub

Private Sub Command2_Click() '停止清0

Label1 = "0"

Label2 = "0"

Label3 = "0"

Timer1Enabled = False

End Sub

Private Sub Form_Load() '初始设置

Label3 = "0"

Label2 = "0"

Label1 = "0"

Timer1Interval = 1000

Timer1Enabled = False

End Sub

Private Sub Timer1_Timer()

Label3 = Label3 + 1

If Label3 = 60 Then

Label3 = "0"

Label2 = Label2 + 1

If Label2 = 60 Then

Label2 = "0"

Label1 = Label1 + 1

End If

End If

End Sub

以上就是关于怎么用VB6.0编一个倒计时程序全部的内容,包括:怎么用VB6.0编一个倒计时程序、Python用time,设计程序,显示20秒倒计时Python用time,设计程序,显示20秒倒计、c语言 倒计时程序等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zz/9779110.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-01
下一篇2023-05-01

发表评论

登录后才能评论

评论列表(0条)

    保存