📄 editinformation.bas
字号:
Attribute VB_Name = "EditInformation"
'判断输入时间是否合法的过程
Public Function CheckTime() As Boolean
Dim FindError As Integer
FindError = 0
Dim year, month, day, week, hour, minute, second As Integer
Dim mytime(1 To 7) As String
year = Val(Main.Time(7))
month = Val(Main.Time(6))
day = Val(Main.Time(5))
week = Val(Main.Time(4))
hour = Val(Main.Time(3))
minute = Val(Main.Time(2))
second = Val(Main.Time(1))
For i = 1 To 7
mytime(i) = Main.Time(i).Text
Next i
'不合法字符判断
For i = 1 To 7
For j = 1 To Len(mytime(i))
If Mid(mytime(i), j, 1) < "0" Or Mid(mytime(i), j, 1) > "9" Then
k = MsgBox("时间中有不合法的字符!", vbCritical, "警告")
Exit Function
End If
Next j
Next i
If mytime(1) = "" And mytime(2) = "" And mytime(3) = "" And mytime(4) = "" And mytime(5) = "" And mytime(6) = "" And mytime(7) = "" Then
FindError = 6
End If
If second < 0 Or second > 59 Or minute < 0 Or minute > 59 Or hour < 0 Or hour > 23 Then
FindError = 1 '时间有误
k = MsgBox("1", vbOKOnly)
End If
If (week <= 0 And mytime(4) <> "") Or week > 7 Or (day <= 0 And mytime(5) <> "") Or day > 31 Or (month <= 0 And mytime(6) <> "") Or month > 12 Then
FindError = 2 '范围有误
k = MsgBox("2", vbOKOnly)
End If
If mytime(1) <> "" And mytime(2) = "" And mytime(3) <> "" Then
FindError = 3
k = MsgBox("3", vbOKOnly)
End If
If mytime(5) <> "" And mytime(4) <> "" Then
FindError = 4 '日期和星期不可同设
k = MsgBox("4", vbOKOnly)
End If
If day <> 0 And year <> 0 And month = 0 Then
FindError = 5 '有日无月
k = MsgBox("5", vbOKOnly)
End If
If (maonth = 4 Or month = 6 Or month = 9 Or month = 11) And day >= 31 Then
FindError = 7
End If
If Not ((year Mod 400 = 0) Or (year Mod 4 = 0 And year Mod 100 <> 0)) And month = 2 And day > 28 Then
FindError = 8
End If
If FindError <> 0 Then
k = MsgBox("输入的日期或时间格式有误,请确认后再填!", vbCritical, "错误提示")
CheckTime = False
Else
CheckTime = True
End If
End Function
'组织字符串
Public Function ZuZhi(n As Integer) As String
Dim mytime(1 To 7) As String
Dim mystr As String
mystr = ""
For i = 1 To 7
mytime(i) = Main.Time(i).Text
Next i
'组织以分为周期
If mytime(7) = "" And mytime(6) = "" And mytime(5) = "" And mytime(4) = "" And mytime(3) = "" And mytime(2) = "" And mytime(1) <> "" Then
If Len(mytime(1)) = 1 Then
mytime(1) = "0" + mytime(1)
End If
mytime(7) = " "
mytime(6) = " "
mytime(5) = " "
mytime(4) = " "
mytime(3) = " "
mytime(2) = " "
'组织以小时为周期
ElseIf mytime(7) = "" And mytime(6) = "" And mytime(5) = "" And mytime(4) = "" And mytime(3) = "" And mytime(2) <> "" Then
For i = 1 To 2
If mytime(i) = "" Then
mytime(i) = "00"
ElseIf Len(mytime(i)) = 1 Then
mytime(i) = "0" + mytime(i)
End If
Next i
mytime(7) = " "
mytime(6) = " "
mytime(5) = " "
mytime(4) = " "
mytime(3) = " "
'组织以天为周期
ElseIf mytime(7) = "" And mytime(6) = "" And mytime(5) = "" And mytime(4) = "" And mytime(3) <> "" Then
For i = 1 To 3
If mytime(i) = "" Then
mytime(i) = "00"
ElseIf Len(mytime(i)) = 1 Then
mytime(i) = "0" + mytime(i)
End If
Next i
mytime(7) = " "
mytime(6) = " "
mytime(5) = " "
mytime(4) = " "
'组织以星期为周期
ElseIf mytime(7) = "" And mytime(6) = "" And mytime(5) = "" And mytime(4) <> "" Then
For i = 1 To 3
If mytime(i) = "" Then
mytime(i) = "00"
ElseIf Len(mytime(i)) = 1 Then
mytime(i) = "0" + mytime(i)
End If
Next i
mytime(5) = " "
mytime(6) = " "
mytime(7) = " "
'组织以月为周期
ElseIf mytime(7) = "" And mytime(6) = "" And mytime(4) = "" And mytime(5) <> "" Then
For i = 1 To 3
If mytime(i) = "" Then
mytime(i) = "00"
ElseIf Len(mytime(i)) = 1 Then
mytime(i) = "0" + mytime(i)
End If
Next i
If Len(mytime(5)) = 1 Then
mytime(5) = "0" + mytime(5)
End If
mytime(4) = " "
mytime(6) = " "
mytime(7) = " "
'组织以年为周期
ElseIf mytime(7) = "" And mytime(4) = "" And mytime(6) <> "" Then
For i = 1 To 3
If mytime(i) = "" Then
mytime(i) = "00"
ElseIf Len(mytime(i)) = 1 Then
mytime(i) = "0" + mytime(i)
End If
Next i
mytime(4) = " "
If mytime(5) = "" Then
mytime(5) = "01"
ElseIf Len(mytime(5)) = 1 Then
mytime(5) = "0" + mytime(5)
End If
If Len(mytime(6)) = 1 Then
mytime(6) = "0" + mytime(6)
End If
mytime(7) = " "
'以世纪为周期
ElseIf mytime(7) <> "" Then
For i = 1 To 3
If mytime(i) = "" Then
mytime(i) = "00"
ElseIf Len(mytime(i)) = 1 Then
mytime(i) = "0" + mytime(i)
End If
Next i
mytime(4) = " "
For i = 5 To 6
If mytime(i) = "" Then
mytime(i) = "01"
ElseIf Len(mytime(i)) = 1 Then
mytime(i) = "0" + mytime(i)
End If
Next i
End If
mystr = Trim(Str$(Main.List.ListCount)) + Space(n) + _
mytime(7) + "/" + mytime(6) + "/" + mytime(5) + " " + mytime(4) + " " + mytime(3) + ":" + mytime(2) + ":" + mytime(1) + " " + Trim(Main.information.Text)
ZuZhi = mystr
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -