Syntax :
Time = expression$
Time$ = timestring$
timestring$ : Time in string format hh:mm:ss
expression$ : Acceptable time format ( more general than timestring$ )
timestring$ : Value
hh : A number between 00 and 23 inclusive
mm : A number between 00 and 59 inclusive
ss : A number between 00 and 59 inclusive
expression$
2:21
2:21 PM
14:21
October 4, 2010 10:11 am
Time = expression$
Time$ = timestring$
timestring$ : Time in string format hh:mm:ss
expression$ : Acceptable time format ( more general than timestring$ )
timestring$ : Value
hh : A number between 00 and 23 inclusive
mm : A number between 00 and 59 inclusive
ss : A number between 00 and 59 inclusive
expression$
2:21
2:21 PM
14:21
October 4, 2010 10:11 am
Option Explicit
Private Sub cmdClose_Click()
End
End Sub
Public Sub ErrMsgBox(str)
MsgBox str
End Sub
Private Sub cmdOk_Click()
Dim intHours As Integer, intMinutes As Integer, intSeconds As Integer
intHours = Val(txtHours.Text)
intMinutes = Val(txtMinutes.Text)
intSeconds = Val(txtSeconds.Text)
If Len(LTrim(txtHours.Text)) > 0 Then
If intHours "Less Then" 0 Or intHours > 23 Then
ErrMsgBox "Hours are not in an acceptable format!"
txtHours.SetFocus
Exit Sub
End If
If intMinutes "Less Then" 0 Or intMinutes > 59 Then
ErrMsgBox "Minutes are not in an acceptable format!"
txtMinutes.SetFocus
Exit Sub
End If
If intSeconds "Less Then" 0 Or intSeconds > 59 Then
ErrMsgBox "Second are not in an acceptable format!"
txtSeconds.SetFocus
Exit Sub
End If
txtTime.Text = Trim(intHours) & " : " & Trim(intMinutes) & " : " & _
Trim(intSeconds)
Time = txtTime.Text
Exit Sub
Else
On Error GoTo BadTime
End If
BadTime:
ErrMsgBox "That time is not in an acceptable format!"
End Sub
Note : Less Then use sing
No comments:
Post a Comment