惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
N
Netflix TechBlog - Medium
宝玉的分享
宝玉的分享
Google DeepMind News
Google DeepMind News
腾讯CDC
G
Google Developers Blog
Martin Fowler
Martin Fowler
Microsoft Security Blog
Microsoft Security Blog
Recent Announcements
Recent Announcements
爱范儿
爱范儿
Engineering at Meta
Engineering at Meta
Microsoft Azure Blog
Microsoft Azure Blog
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
有赞技术团队
有赞技术团队
Jina AI
Jina AI
人人都是产品经理
人人都是产品经理
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
M
MIT News - Artificial intelligence
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
美团技术团队
WordPress大学
WordPress大学
阮一峰的网络日志
阮一峰的网络日志

博客园 - Blaze

eVC++就是eVC++啊 - Blaze - 博客园 VC++常用数据类型及其操作详解[徐兆元] From VB.NET to C# and Back Again [By Darren Neimke and Scott Mitchell ] 请不要做浮躁的人(老文了,还是转一下,共勉) 地球上最慢的网路不在巴布里亚新几内亚和尼泊尔之间,而在中国网通和电信之间! [翻译]用TcpClient建立GPRS连接 1年零2个月零25天 我回来了 .NET的Pascal--Chrome来了! Gmail疯了?50个邀请! 检举个博客园的Bug! INI配置文件的替代品-XML配置文件的操作 INI的替代品--XML配置文件读取与保存 Wallop下蛋送邀请。 从WebService的SessionID说起 Gmail下蛋了 udp的奇怪问题 webservice对"小"规模数据传输的效率问题 运动会痛苦经历 n个VB.Net C#代码转换工具
关于时间的加减计算
Blaze · 2004-10-16 · via 博客园 - Blaze

前几天论坛上有人问我时间加减运算的办法,也就是类似5:5+6:6=11:11。
于是有了代码:

        Dim temp_h, temp_m As Double
        
Select Case Op
            
Case "+"
                T2 = Split(TxtTime.Text, ":")
                
If T2.Length = 2 Then
                    temp_m 
= CDbl(T1(1)) + CDbl(T2(1))
                    temp_h 
= CDbl(T1(0)) + CDbl(T2(0))
                    
If temp_m >= 60 And temp_m < 120 Then
                        temp_h 
+= 1
                        temp_m 
-= 60
                        TxtTime.Text 
= CStr(temp_h) + ":" + CStr(temp_m)
                        ListBox1.Items.Add(TxtTime.Text)
                    
ElseIf temp_m >= 0 And temp_m < 60 Then
                        TxtTime.Text 
= CStr(temp_h) + ":" + CStr(temp_m)
                        ListBox1.Items.Add(TxtTime.Text)
                    
ElseIf temp_m >= 120 Then
                        
MsgBox("分钟数错误")
                    
End If
                
Else
                    
MsgBox("仅允许一个冒号")
                    Op 
= ""
                    Exit Sub
                
End If
            
Case "-"
                T2 = Split(TxtTime.Text, ":")
                
If T2.Length = 2 Then
                    temp_m 
= CDbl(T1(1)) - CDbl(T2(1))
                    temp_h 
= CDbl(T1(0)) - CDbl(T2(0))
                    
If temp_m < 0 And temp_m >= -60 Then
                        temp_h 
-= 1
                        temp_m 
+= 60
                        TxtTime.Text 
= CStr(temp_h) + ":" + CStr(temp_m)
                        ListBox1.Items.Add(TxtTime.Text)
                    
ElseIf temp_m >= 0 And temp_m < 60 Then
                        TxtTime.Text 
= CStr(temp_h) + ":" + CStr(temp_m)
                        ListBox1.Items.Add(TxtTime.Text)
                    
ElseIf temp_m <= -120 Then
                        
MsgBox("分钟数错误")
                    
End If
                
Else
                    
MsgBox("仅允许一个冒号")
                    Op 
= ""
                    Exit Sub
                
End If
            
Case ""
                    Exit Sub
        
End Select

不过有了新问题,类似7:85这样的非标准时间不能算,于是将加减代码换掉。可是新的问题又来了,他们想一次输入数据类似1:1+2:2+3:3= 一次计算。我有想到了原来写的一个表达式解析类。这个实在太复杂,正则表达式应该ok。徘徊中~~~