My Apologise,
Doe this help?
Private Sub cmdcalculate_Click()
TextBox1 = TextBox1.Text
TextBox2 = TextBox2.Text
TextBox3 = Format(CDate(TextBox2) - CDate(TextBox1), "h:mm")
End Sub
Private Sub cmdclearinfo_Click()
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
End Sub
Private Sub cmdexist_Click()
Unload UserForm1
End Sub
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If Not Me.TextBox1 Like "??:??" Then
MsgBox "Please use format 'hh:mm'"
Cancel = True
Exit Sub
Else
End If
myVar = Application.WorksheetFunction.Text(Me.TextBox1, "hh:mm am/pm")
Me.TextBox1 = myVar
End Sub
Private Sub TextBox2_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If Not Me.TextBox2 Like "??:??" Then
MsgBox "Please use format 'hh:mm'"
Cancel = True
Exit Sub
Else
End If
myVar = Application.WorksheetFunction.Text(Me.TextBox2, "hh:mm am/pm")
Me.TextBox2 = myVar
End Sub
Bookmarks