大家帮我看看一个简单的时间类,为什么不能显示?

koko214 2003-09-29 06:21:46
Option Explicit

'类模块

Private mHour As Integer
Private mMinute As Integer
Private mSecond As Integer

Public Sub SetTime(ByVal h As Integer, ByVal m As Integer, ByVal s As Integer)
mHour = IIf((h >= 0 And h < 24), h, 0)
mMinute = IIf((m >= 0 And m < 60), m, 0)
mSecond = IIf((s >= 0 And s < 60), s, 0)

End Sub


Public Function ToFormatTime() As String '24小时制
ToFormatTime = Format$(mHour, "00") & ":" & Format$(mMinute, "00") & ":" & Format$(mSecond, "00")

End Function

Public Function ToStandardTime() As String '(12小时制)
Dim h As Integer

h = IIf((mHour = 12 Or mHour = 0), 12, mHour Mod 12)

ToStandardTime = h & ":" & Format$(mMinute, "00") & ":" & Format$(mSecond, "00") & " " & IIf(mHour < 12, "AM", "PM")


End Function


'form窗体里的代码
Option Explicit

Private Sub Form_Load()
Dim t As New CTime '调用类

Print "标准时间为:" & t.ToStandardTime()
Print "24小时制时间为:" & t.ToFormatTime()
Print

Call t.SetTime(17, 28, 46)

Print "标准时间为:" & t.ToStandardTime()
Print "24小时制时间为:" & t.ToFormatTime()

End Sub

运行后为什么窗体上什么都没显示?
...全文
33 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
qinyonlhm 2003-09-29
  • 打赏
  • 举报
回复
Private Sub Form_Load()
Dim t As New Class1 '调用类

Debug.Print "标准时间为:" & t.ToStandardTime()
Debug.Print "24小时制时间为:" & t.ToFormatTime()
Print

Call t.SetTime(17, 28, 46)

Debug.Print "标准时间为:" & t.ToStandardTime()
Debug.Print "24小时制时间为:" & t.ToFormatTime()

End Sub

在立即窗口看一下.可以了.
或者

Private Sub Form_Load()
Dim t As New Class1 '调用类
Form1.AutoRedraw = True
Print "标准时间为:" & t.ToStandardTime()
Print "24小时制时间为:" & t.ToFormatTime()

Call t.SetTime(17, 28, 46)

Print "标准时间为:" & t.ToStandardTime()
Print "24小时制时间为:" & t.ToFormatTime()

'
End Sub
佛的光辉 2003-09-29
  • 打赏
  • 举报
回复
同意楼上的,加上
Me.AutoRedraw = True
busisoft 2003-09-29
  • 打赏
  • 举报
回复
修改如下:
'form窗体里的代码
Option Explicit

Private Sub Form_Load()
Dim t As New Ctime '调用类

Me.AutoRedraw = True

Print "标准时间为:" & t.ToStandardTime()
Print "24小时制时间为:" & t.ToFormatTime()
Print

Call t.SetTime(17, 28, 46)

Print "标准时间为:" & t.ToStandardTime()
Print "24小时制时间为:" & t.ToFormatTime()

End Sub

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧