Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Time format will not exclude seconds!!

I'm trying to capture a start time and end time entered into a userform
and my program refuses to exclude the seconds!!! here's my code:

Dim chkStartTime As String
Dim chkEndTime As String
Dim StartTime As Date
Dim EndTime As Date

chkStartTime = FrmDataInput.txtStartTime.Value
chkEndTime = FrmDataInput.txtEndTime.Value

If IsDate(chkStartTime) = False Then
MsgBox "Please enter a valid start time in HH:MM AM/PM format.",
vbOKOnly
FrmDataInput.txtStartTime.SetFocus
Exit Sub
Else
StartTime = Format(chkStartTime, "hh:mm AM/PM")
End If

If IsDate(chkEndTime) = False Then
MsgBox "Please enter a valid end time in HH:MM AM/PM format.",
vbOKOnly
FrmDataInput.txtEndTime.SetFocus
Exit Sub
Else
EndTime = Format(chkEndTime, "HH:MM AM/PM")
End If


When I step through the code and add a watch to the StartTime and End
time I get hh:mm:ss AM/PM!!!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Time format will not exclude seconds!!

Shelley,

Either format StartTime and EndTime as Strings, or whenever you use them as date/times, use
Format(StartTime, "HH:MM AM/PM")

HTH,
Bernie
MS Excel MVP


"sbowman" wrote in message
ups.com...
I'm trying to capture a start time and end time entered into a userform
and my program refuses to exclude the seconds!!! here's my code:

Dim chkStartTime As String
Dim chkEndTime As String
Dim StartTime As Date
Dim EndTime As Date

chkStartTime = FrmDataInput.txtStartTime.Value
chkEndTime = FrmDataInput.txtEndTime.Value

If IsDate(chkStartTime) = False Then
MsgBox "Please enter a valid start time in HH:MM AM/PM format.",
vbOKOnly
FrmDataInput.txtStartTime.SetFocus
Exit Sub
Else
StartTime = Format(chkStartTime, "hh:mm AM/PM")
End If

If IsDate(chkEndTime) = False Then
MsgBox "Please enter a valid end time in HH:MM AM/PM format.",
vbOKOnly
FrmDataInput.txtEndTime.SetFocus
Exit Sub
Else
EndTime = Format(chkEndTime, "HH:MM AM/PM")
End If


When I step through the code and add a watch to the StartTime and End
time I get hh:mm:ss AM/PM!!!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Time format will not exclude seconds!!

Thank You!! It works if I use Format(StartTime, "HH:MM AM/PM") whenever
I use the variable. It sucks to have to do that, but it works and
that's what matters.

Shelley

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Format time to not include seconds and AM/PM Diana New Users to Excel 2 August 8th 08 06:31 PM
how do i convert standard time format into seconds? Raj Excel Discussion (Misc queries) 4 May 29th 06 04:56 PM
display no seconds in time format [h] Finolac Excel Discussion (Misc queries) 1 October 3rd 05 03:19 PM
Convert "Time Interval" in "hours : minutes : seconds" to seconds Ianukotnorth New Users to Excel 7 May 8th 05 08:11 PM
Exclude AM/PM from time format flawed Excel Programming 3 November 20th 03 07:52 PM


All times are GMT +1. The time now is 10:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"