Option Explicit'类模块Private mHour As Integer
Private mMinute As Integer
Private mSecond As IntegerPublic 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 FunctionPublic 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 ExplicitPrivate 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运行后为什么窗体上什么都没显示?
Private mMinute As Integer
Private mSecond As IntegerPublic 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 FunctionPublic 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 ExplicitPrivate Sub Form_Load()
Dim t As New CTime '调用类
Print "标准时间为:" & t.ToStandardTime()
Print "24小时制时间为:" & t.ToFormatTime()
Call t.SetTime(17, 28, 46)
Print "标准时间为:" & t.ToStandardTime()
Print "24小时制时间为:" & t.ToFormatTime()
End Sub运行后为什么窗体上什么都没显示?
解决方案 »
- VB6的MSHFlexGrid转换为VB2005的DataGridView,急!
- 关于这个“农民公寓”的问题
- vb的数据报表(data report)点击关闭时,报windows错误并导致整个程序退出。
- vb中如何初始化大二维数组
- VB ----fso对txt文件进行追加记录啊! ---在线等!有结果马上结贴!谢谢
- 老手请进,想做一个大点的管理系统,求报表、表格第三方控件(来者有分)
- 有北京的朋友吗?25号左右去北京玩两天
- 请给我这个机会,分不够再加
- recordset做二次查询
- @@@@@返回两个数相除的余数,用什么函数?
- 高分!!!如何设计一这样的数护库表,要实现的功能如下:UP有分。。。
- 书签 问题 就20分 高手赐教 (另外请问如何传数组)
'form窗体里的代码
Option ExplicitPrivate 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
Me.AutoRedraw = True
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