VB實(shí)現(xiàn)的倒計(jì)時(shí)類代碼詳解
更新時(shí)間:2014年07月31日 10:36:09 投稿:shichen2014
這篇文章主要介紹了VB實(shí)現(xiàn)的倒計(jì)時(shí)類代碼,非常實(shí)用的功能,需要的朋友可以參考下
本文所述為用VB制作倒計(jì)時(shí)程序用到的一個(gè)Module類代碼,是基于控制臺(tái)的倒計(jì)時(shí)程序,可供VB初學(xué)者或者VB愛好者參考學(xué)習(xí),當(dāng)然讀者也可以將其拷貝代碼到VB工程里面直接使用,不過需要自己創(chuàng)建相關(guān)的代碼,對(duì)于初學(xué)者來說,也是很容易看懂的一段代碼。
具體功能代碼如下:
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("本程序?yàn)榈褂?jì)時(shí)程序,請(qǐng)分部輸入需要倒數(shù)的小時(shí)數(shù)、分鐘數(shù)、秒數(shù)")
Console.WriteLine("請(qǐng)輸入計(jì)時(shí)的小時(shí)數(shù)(大于等于0的整數(shù)):")
h = Console.ReadLine()
Console.WriteLine("請(qǐng)輸入計(jì)時(shí)的總分鐘數(shù)(大于等于0并且小于60的整數(shù)):")
m = Console.ReadLine()
Console.WriteLine("請(qǐng)輸入計(jì)時(shí)的秒數(shù)(大于等于0的并且小于60的整數(shù)):")
s = Console.ReadLine()
Console.WriteLine("當(dāng)前系統(tǒng)時(shí)間為:{0}", h)
a = Now()
Console.WriteLine("當(dāng)前系統(tǒng)時(shí)間為:{0}", a)
Console.WriteLine(" ")
Console.WriteLine(" **************倒計(jì)時(shí)開始***************** ")
Console.WriteLine(" **************倒計(jì)時(shí)開始***************** ")
Console.WriteLine(" **************倒計(jì)時(shí)開始***************** ")
Console.WriteLine(" **************倒計(jì)時(shí)開始***************** ")
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}小時(shí){1}分{2}秒", h, m, s)
If (h <= 0) And (m <= 0) And (s <= 0) Then
Console.WriteLine("倒計(jì)時(shí)完畢,隨意輸入字符將退出程序:")
Exit For
End If
End If
If s = 0 Then
If m > 0 Then
m = m - 1
s = 59
Console.WriteLine(" 剩余:{0}小時(shí){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}小時(shí){1}分{2}秒 ", h, m, s)
If (h <= 0) And (m <= 0) And (s <= 0) Then
Console.WriteLine("倒計(jì)時(shí)完畢,隨意輸入字符將退出程序:")
Exit For
End If
End If
End If
Next
Console.Read()
End Sub
End Module
您可能感興趣的文章:
- 簡(jiǎn)單易用的倒計(jì)時(shí)js代碼
- Android實(shí)現(xiàn)加載廣告圖片和倒計(jì)時(shí)的開屏布局
- Delphi實(shí)現(xiàn)毫秒級(jí)別的倒計(jì)時(shí)實(shí)例代碼
- jquery實(shí)現(xiàn)倒計(jì)時(shí)代碼分享
- php+js實(shí)現(xiàn)倒計(jì)時(shí)功能
- timespan使用方法詳解
- C#實(shí)現(xiàn)線程安全的簡(jiǎn)易日志記錄方法
- C#與js實(shí)現(xiàn)去除textbox文本框里面重復(fù)記錄的方法
- C#實(shí)現(xiàn)獲取一年中是第幾個(gè)星期的方法
- C#基于TimeSpan實(shí)現(xiàn)倒計(jì)時(shí)效果的方法
相關(guān)文章
淺談如何使用vb.net從數(shù)據(jù)庫(kù)中提取數(shù)據(jù)
這篇文章主要介紹了淺談如何使用vb.net從數(shù)據(jù)庫(kù)中提取數(shù)據(jù),使用VB提取數(shù)據(jù),是先查找,做成數(shù)組,再顯示到數(shù)據(jù)里,如果感興趣可以了解一下2020-07-07
VB的TextBox文本框?qū)崿F(xiàn)垂直居中顯示的方法
這篇文章主要介紹了VB的TextBox文本框?qū)崿F(xiàn)垂直居中顯示的方法,比較實(shí)用的功能,需要的朋友可以參考下2014-07-07
VB實(shí)現(xiàn)的16位和32位md5加密代碼分享
這篇文章主要介紹了VB實(shí)現(xiàn)的16位和32位md5加密代碼分享,需要的朋友可以參考下2014-07-07
VB讀取線程、句柄及寫入內(nèi)存的API代碼實(shí)例
這篇文章主要介紹了VB讀取線程、句柄及寫入內(nèi)存的API代碼實(shí)例,需要的朋友可以參考下2014-07-07

