欢迎来到代码驿站!

当前位置:首页 >

VB实现的倒计时类代码详解

时间:2021-01-18 14:42:51|栏目:|点击:

本文所述为用VB制作倒计时程序用到的一个Module类代码,是基于控制台的倒计时程序,可供VB初学者或者VB爱好者参考学习,当然读者也可以将其拷贝代码到VB工程里面直接使用,不过需要自己创建相关的代码,对于初学者来说,也是很容易看懂的一段代码。

具体功能代码如下:

Module Module1 
Sub Main() 
Dim a As Date 
Dim h, m, s As Integer 
Dim n, i As Long 
Dim x, z As Long 
Dim y As Long 
Console.WriteLine("本程序为倒计时程序,请分部输入需要倒数的小时数、分钟数、秒数") 
Console.WriteLine("请输入计时的小时数(大于等于0的整数):") 
h = Console.ReadLine() 
Console.WriteLine("请输入计时的总分钟数(大于等于0并且小于60的整数):") 
m = Console.ReadLine() 
Console.WriteLine("请输入计时的秒数(大于等于0的并且小于60的整数):") 
s = Console.ReadLine() 
Console.WriteLine("当前系统时间为:{0}", h) 
a = Now() 
Console.WriteLine("当前系统时间为:{0}", a) 
Console.WriteLine(" ") 
Console.WriteLine(" **************倒计时开始***************** ") 
Console.WriteLine(" **************倒计时开始***************** ") 
Console.WriteLine(" **************倒计时开始***************** ") 
Console.WriteLine(" **************倒计时开始***************** ") 
z = 0 
x = 60 
For i = 0 To h * 3600 + m * 60 + s 
For n = 0 To 6000000 
For y = 0 To 25 
z = z + 1 
Next 
Next 
If (h <= 0) And (m <= 0) And (s <= 0) Then Exit For 
If s > 0 Then 
s = s - 1 
Console.WriteLine(" 剩余:{0}小时{1}分{2}秒", h, m, s) 
If (h <= 0) And (m <= 0) And (s <= 0) Then 
Console.WriteLine("倒计时完毕,随意输入字符将退出程序:") 

Exit For 
End If 
End If 
If s = 0 Then 
If m > 0 Then 
m = m - 1 
s = 59 
Console.WriteLine(" 剩余:{0}小时{1}分{2}秒 ", h, m, s) 
End If 

If m = 0 And h > 0 And s = 0 Then 
h = h - 1 
m = 59 
s = 59 
Console.WriteLine(" 剩余:{0}小时{1}分{2}秒 ", h, m, s) 
If (h <= 0) And (m <= 0) And (s <= 0) Then 
Console.WriteLine("倒计时完毕,随意输入字符将退出程序:") 
Exit For 
End If 
End If 
End If 
Next 
Console.Read() 
End Sub 
End Module

上一篇:PowerShell使用正则表达式查找字符串实例

栏    目:

下一篇:Powershell小技巧之通过EventLog查看近期电脑开机和关机时间

本文标题:VB实现的倒计时类代码详解

本文地址:http://www.codeinn.net/misctech/46806.html

推荐教程

广告投放 | 联系我们 | 版权申明

重要申明:本站所有的文章、图片、评论等,均由网友发表或上传并维护或收集自网络,属个人行为,与本站立场无关。

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:914707363 | 邮箱:codeinn#126.com(#换成@)

Copyright © 2020 代码驿站 版权所有