/*做一个2:00的倒计时,但是失败了,问题在哪。C语言。*/
2014-08-01 19:06
429 查看
/*做一个2:00的倒计时,但是失败了,问题在哪。C语言。*/
c#
vb
用C#的timer控件 做一个 倒计时的 东东~ 怎么搞来的。怎么给Timer设置 值啊
vb:
VB:设定日期范围倒计时
/*做一个2:00的倒计时,但是失败了,问题在哪。C语言。*/
/*做一个2:00的倒计时,但是失败了,问题在哪。C语言。*/ int a = 2, b = 60, c; while (a >= 0) { if (b == 60) c = 0; else c = b; //system("cls"); if (c > 9) printf_s("%d:%d.", a, c); else printf_s("%d:0%d.", a, c); Sleep(1000); if (--b == 0) b = 60; if (b == 59) a--; }
int a = 2, b = 60, c; while (a >= 0) { c = (b == 60) ? 0 : b; system("cls"); printf_s((c > 9) ? "%d:%d " : "%d:0%d ", a, c); Sleep(1000); if (!--b) b = 60; if (b == 59) a--; }
c#
int a = 2, b = 60, c; while (a >= 0) { c = (b == 60) ? 0 : b; Console.WriteLine((c > 9) ? "{0}:{1} " : "{0}:{1} ", a, c); Thread.Sleep(1000); if (--b == 0) b = 60; if (b == 59) a--; }
vb
Dim shijian As DateTime = DateTime.Parse("0:5:0") Dim miao As Integer = shijian.Second Dim a = 5 * 60 Do While a > 0 miao -= 1 a -= 1 Console.WriteLine(shijian.AddSeconds(miao).ToLongTimeString) System.Threading.Thread.Sleep(1000) Loop
用C#的timer控件 做一个 倒计时的 东东~ 怎么搞来的。怎么给Timer设置 值啊
public Form1() { InitializeComponent(); System.Timers.Timer 定时 = new System.Timers.Timer(1000); 定时.Elapsed += new System.Timers.ElapsedEventHandler(计时事件); 定时.Enabled = true; Label 显示 = new Label(); 显示.Name = "显示"; 显示.Parent = this; /*之下设置指定时间和秒*/ 时间 = DateTime.Parse("14:46"); 减 = 时间.Second + 4; } DateTime 时间 = DateTime.Now; int 减 = DateTime.Now.Second; void 计时事件(object sender, EventArgs e) { this.Invoke(new Action(() => { this.Controls["显示"].Text = 时间.AddSeconds(减--).TimeOfDay.ToString(); })); }
vb:
Dim 计数 As Integer = 0 Dim 设置时间 As DateTime = DateTime.Parse("0:5:0") Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click 设置时间 = DateTime.Parse("0:1:0") TextBox1.Text = 设置时间.ToLongTimeString 时钟.Start() End Sub Private Sub 时钟_Tick(sender As Object, e As EventArgs) Handles 时钟.Tick 计数 -= 1 TextBox1.Text = 设置时间.AddSeconds(计数).ToLongTimeString If DateTime.Parse(TextBox1.Text).Minute = 0 And DateTime.Parse(TextBox1.Text).Second <= 10 Then Console.Beep() If DateTime.Parse(TextBox1.Text).Minute = 0 And DateTime.Parse(TextBox1.Text).Second = 0 Then 时钟.Stop() End Sub
VB:设定日期范围倒计时
Dim 时间范围 = DateTime.Parse("2015-2-1") - DateTime.Now 文本框.Text = 时间范围.Days.ToString + "天" + 时间范围.Hours.ToString + ":" + 时间范围.Minutes.ToString + ":" + 时间范围.Seconds.ToString 设置时间 = DateTime.Parse(时间范围.ToString.Split(".")(1)) 时钟.Start() Private Sub 时钟_Tick(sender As Object, e As EventArgs) Handles 时钟.Tick 计数 -= 1 Dim 倒计时 = 文本框.Text.Split("天"), 倒计天 As Integer = Integer.Parse(倒计时(0)) 文本框.Text = 倒计时(0) + "天" + 设置时间.AddSeconds(计数).ToLongTimeString If DateTime.Parse(倒计时(1)).Minute = 0 And DateTime.Parse(倒计时(1)).Second <= 10 Then Console.Beep() If DateTime.Parse(倒计时(1)).Hour = 0 And DateTime.Parse(倒计时(1)).Minute = 0 And DateTime.Parse(倒计时(1)).Second = 0 Then 倒计天 -= 1 文本框.Text = 倒计天.ToString + "天" + 设置时间.AddSeconds(计数).ToLongTimeString End If If DateTime.Parse(倒计时(1)).Hour = 0 And DateTime.Parse(倒计时(1)).Minute = 0 And DateTime.Parse(倒计时(1)).Second = 0 And 倒计天 = 0 Then 时钟.Stop() End Sub
相关文章推荐
- 【微信支付】分享一个失败的案例 跨域405(Method Not Allowed)问题 关于IM的一些思考与实践 基于WebSocketSharp 的IM 简单实现 【css3】旋转倒计时 【Html5】-- 塔台管制 H5情景意识 --飞机 谈谈转行
- 现在有这样一个问题 我把上W条数据插入表内,但是发现还有一条数据没进入表里.我想查出来是哪个数据没进去. 能用查询语句查出来吗?
- 一个tomcat启动失败问题
- C语言一个简单问题
- 终于结束了一个郁闷+棘手的问题,但是却迎来了新的问题!!!!超级郁闷~~~~~
- 请大家看一下一个c语言中的链表问题,下面的代码是有错误的!!请大家说出错误的原因,以及修改的方法!!!
- 关于C语言For循环的一个问题~!
- 昨天遇到的一个断言失败,程序退出的问题
- 一个C语言的问题
- 一个简单的C语言嵌套问题
- 解决Protege使用中的一个问题:从已有owl文件建立项目失败(w3china)
- SQL SERVER 2005的一个怪问题: 在查询结果面板中编辑失败.
- 关于C语言中printf函数的一个问题
- 一个关于C语言二维数组问题
- 我似乎不能成功定义一个链表。我试过 typedef struct { char *item; NODEPTR next; } *NODEPTR; 但是编译器报了错误信息。难道在C语言中一个结构不能包
- 一个生成失败,却可以调试的奇怪问题
- 我用c语言写了一个关于商人过河的问题
- 一个c语言的问题
- 请教一个C语言问题
- 学习DX编程中的一个很丢脸,但是不知道是为什么的问题