| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 475 人关注过本帖
标题:[讨论]这是我写的/有几个问题想请教
只看楼主 加入收藏
hundnn
Rank: 1
等 级:新手上路
帖 子:123
专家分:0
注 册:2007-8-23
收藏
 问题点数:0 回复次数:3 
[讨论]这是我写的/有几个问题想请教

那道练习题是这样的:[设把输入的秒数转化成几天几时几秒(没有几分)]
下面是我写的,不过这可是VB书上一道小小的编程/我这样写明显太繁琐了。有更简单的方法吗?(我是小鸟,请说地详细些。谢谢了)
----------------------------------------------------
Private Sub Form_Click()
Dim zongmiao As Long, hour1 As Integer, second1 As Integer, _
days As Long, hour2 As Integer, yvmiao As Long, second2 As Integer
tishi$ = "请输入要转换的总秒数"
zongmiao = InputBox(tishi$)
If zongmiao < 3600 Then
Print zongmiao; "秒="; "0天0时"; Str$(zongmiao); "秒"
ElseIf zongmiao >= 3600 And zongmiao < 86400 Then
hour1 = zongmiao \ 3600
second1 = zongmiao Mod 3600
Print zongmiao; "秒="; "0天"; hour1; "时"; second1; "秒"
Else
days = zongmiao \ 86400
yvmiao = zongmiao Mod 86400
If yvmiao >= 3600 Then
hour2 = yvmiao \ 3600
second2 = yvmiao Mod 3600
Print zongmiao; "秒="; days; "天"; hour2; "时"; second2; "秒"
Else
Print zongmiao; "秒="; days; "天"; "0时"; yvmiao; "秒"
End If
End If


End Sub

----------------------------------------------------

搜索更多相关主题的帖子: 编程 练习题 小鸟 
2007-09-01 12:17
hundnn
Rank: 1
等 级:新手上路
帖 子:123
专家分:0
注 册:2007-8-23
收藏
得分:0 
自己坐沙发//~~


达人们/别偷懒了/帮下忙先
2007-09-01 13:18
slore
Rank: 5Rank: 5
等 级:贵宾
威 望:16
帖 子:1108
专家分:0
注 册:2005-7-1
收藏
得分:0 

感觉你搞麻烦了=。=

Option Explicit

Private Sub command1_Click()
Dim zongmiao As Long, yvmiao As Long
Dim
days As Long, Hours As Integer, Seconds As Integer
zongmiao = InputBox("请输入要转换的总秒数")
days = zongmiao \ 86400
yvmiao = zongmiao Mod 86400
Hours = yvmiao \ 3600
Seconds = yvmiao Mod 3600
Print zongmiao; "秒="; days; ""; Hours; ""; Seconds; ""
End Sub

[此贴子已经被作者于2007-9-1 13:22:39编辑过]


快上课了……
2007-09-01 13:21
hundnn
Rank: 1
等 级:新手上路
帖 子:123
专家分:0
注 册:2007-8-23
收藏
得分:0 

长见识了/
还来整数除可以商零啊/
多谢版版
看来我是把简单事情复杂化了/呵呵/学到了

2007-09-01 16:31
快速回复:[讨论]这是我写的/有几个问题想请教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016037 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved