|
-
Apr 9th, 2003, 08:44 AM
#1
Thread Starter
Addicted Member
24 HRS Format
Can we set the format of Date time picker to 24 Hours instead of 12 AM/PM ??
Thanks
-
Apr 9th, 2003, 09:29 AM
#2
Frenzied Member
VB Code:
Private Sub Form_Load()
DTPicker1.Format = dtpCustom
DTPicker1.CustomFormat = Format(Now, "HH:MM:SS")
DTPicker1.Value = Now()
End Sub
-
Apr 9th, 2003, 09:57 AM
#3
Don't know why that works, but shouldn't it be:
VB Code:
DTPicker1.CustomFormat = "HH:mm:ss"
???
Woka
-
Apr 9th, 2003, 10:00 AM
#4
Frenzied Member
Do you see any major diffence between "HH:mm:ss" and Format(Now, "HH:MM:SS") ???
Last edited by McGenius; Apr 9th, 2003 at 10:04 AM.
McGenius
-
Apr 9th, 2003, 10:03 AM
#5
Why?
The code I posted above seems more logical, and works...
Woka
-
Apr 9th, 2003, 10:05 AM
#6
Frenzied Member
Originally posted by Wokawidget
... The code I posted above seems more logical ...
In what sense?
-
Apr 9th, 2003, 10:11 AM
#7
Because your code essentially does:
VB Code:
DTPicker1.CustomFormat = "16:08:34"
Which means nothing...it works, but I don't know why...
It's easier to read and debug, IN MY OPINION, if you use:
VB Code:
DTPicker1.CustomFormat = "HH:mm:ss"
However, as you have stated before, I post stupid and pointless things...
Maybe it's just me...
Woka
-
Apr 9th, 2003, 10:13 AM
#8
MCGenius, not to gang up on your or anything.
I just tried your code and although it does show the correct time, my datepicker control is basically disabled. I cannot change the date using the scrollbars, manually etc.. nothing.
The CustomFormat property is used to specify the date format not an actual date, as in your code.
-
Apr 9th, 2003, 10:16 AM
#9
And McGenius's code doesn't work properly.
It displays the time correct, but the control can't be editted anymore. It seems to be read-only.
It seems useless to use the calender if you only display time, so I set the updown property to true. Editing the time with McGenius's code doesn't seem to work, while the following code works fine.
VB Code:
Private Sub Form_Load()
DTPicker1.Format = dtpCustom
DTPicker1.CustomFormat = "HH:mm:ss"
DTPicker1.UpDown = True
DTPicker1.Value = Now()
End Sub
-
Apr 9th, 2003, 10:19 AM
#10
Frenzied Member
Originally posted by brucevde
... The CustomFormat property is used to specify the date format not an actual date, as in your code.
And that's what it's for ...
-
Apr 9th, 2003, 10:23 AM
#11
Frenzied Member
Originally posted by Frans C
...It displays the time correct, but the control can't be editted anymore. It seems to be read-only...
That's entirely different issue.
Although, when I need to buy say pair of shoes - I 'll buy it from a shoe store (not from a department store that knows very little about the shoes). The same if I need to format some string I would always use Format function and nothing less than that.
-
Apr 9th, 2003, 10:23 AM
#12
The court has over-ruled McGenius...
Woka wins 
I thought the code did work, but my testing was limited and I didn't try the up and downy things 
Woka
-
Apr 9th, 2003, 10:26 AM
#13
Originally posted by McGenius
That's entirely different issue.
Although, when I need to buy say pair of shoes - I 'll buy it from a shoe store (not from a department store that knows very little about the shoes). The same if I need to format some string I would always use Format function and nothing less than that.
What?! What have shoes got to do with the price of fish? 
The Format, or Format$, commands do format data into the desired format, BUT you can't pass this into CustomFormat property as this requires "HH:mm:ss" or something along those lines...
Woka
-
Apr 9th, 2003, 10:33 AM
#14
Code inside the DatePicker control will do something like:
VB Code:
Option Explicit
Private mstrFormat As String
Private mdteValue As Date
Public Property Let CustomFormat(ByVal pstrValue As string)
mstrFormat = pstrValue
RefreshDisplay
End Property
Public Property Get CustomFormat() As String
CustomFormat = mstrFormat
End Property
Public Property Let Value(ByVal pdteValue As date)
mdteValue = pdteValue
RefreshDisplay
End property
Public Property Get Value() As Date
Value = mdteValue
End Property
Private Sub RefreshDisplay()
txtDisplay.Text = Format$(mdteValue, mstrFormat)
End Sub
Since you use:
VB Code:
DTPicker1.CustomFormat = Format(Now, "HH:MM:SS")
Then mstrFormat will equal something like 16:32:28
So when it comes to display the data in the RefreshDisplay sub you will infact actually be doing:
VB Code:
Private Sub RefreshDisplay()
txtDisplay.Text = Format$(mdteValue, "16:32:28")
End Sub
Which will basically just assign some random text to the text box. This is why it can't be edited as the datepicker control doesn't recognise any part of this as a date or time...
Woka
-
Apr 9th, 2003, 10:36 AM
#15
A test to check it works is run your code, with the following added...then wait 10-20 seconds, and click the command button and see if the value in the DP gets updated 
VB Code:
Private Sub Command1_Click()
DatePicker1.Value = Now
End Sub
Nothing happens, the display WILL NEVER change since your custom format is random text and is not recognised...
Woka
-
Apr 9th, 2003, 10:38 AM
#16
Frenzied Member
You are real moron, Woka ...
-
Apr 9th, 2003, 10:42 AM
#17
As I noticed before, a discussion with McGenius isn't really worth the effort.
-
Apr 9th, 2003, 10:47 AM
#18
Originally posted by McGenius
You are real moron, Woka ...
I take it you don't fancy a pint sometime then...?
Woka
-
Apr 9th, 2003, 11:11 AM
#19
Frenzied Member
Originally posted by Frans C
As I noticed before, a discussion with McGenius isn't really worth the effort.
I will take any opinion than does make sense, but if you don't have one - don't bother ...
-
Apr 9th, 2003, 11:15 AM
#20
Retired VBF Adm1nistrator
Jesus christ would you stop trying to annoy people!!!
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Apr 9th, 2003, 11:17 AM
#21
Frenzied Member
-
Apr 9th, 2003, 12:10 PM
#22
Originally posted by McGenius
I will take any opinion than does make sense, but if you don't have one - don't bother ...
That doesn't make sense...! 
Unlike your VB code you posted...oh, no, wait...That didn't make sense either 
Woka
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|