Calendar drop-down box
Moderators: Dorian (MJT support), JRL
- tony_smith
- Pro Scripter
- Posts: 70
- Joined: Wed May 14, 2003 8:25 pm
- Location: Vancouver BC Canada
Calendar drop-down box
Anyone out there know how to make a calendar selection box with VB? I don't know VB very well, but I have used some canned VB routines within my MSched scripts.
I am using the input> command to have the user enter a date field and then a time field, these are then used as arguments in running an application through Run Program>. The job fails if these inputs do not conform exactly to the local settings, so I want to take away some kestrokes from the user and make the application more friendly.
Thanks for any help you can give.
I am using the input> command to have the user enter a date field and then a time field, these are then used as arguments in running an application through Run Program>. The job fails if these inputs do not conform exactly to the local settings, so I want to take away some kestrokes from the user and make the application more friendly.
Thanks for any help you can give.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
No time to look now, but I would bet that you can find a free command line popup calendar tool.
Try to Google for "calendar tool" vbscript or "date picker" vbscript. Include vbscript with each phrase to help filter out some java script tools (unless you want to use java scripts).
Try to Google for "calendar tool" vbscript or "date picker" vbscript. Include vbscript with each phrase to help filter out some java script tools (unless you want to use java scripts).
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
- tony_smith
- Pro Scripter
- Posts: 70
- Joined: Wed May 14, 2003 8:25 pm
- Location: Vancouver BC Canada
Date Picker
Did anyone ever find a suitable date picker that works with MS? And if so do you have a sampe to view. I have looked and they all seem to be either Java based or ASP with vbscript. Which would make for a funny looking interface as you would be in an MS Dialog and then Internet Explorer would open to get a date.
It would be nice to have this built into MS in a Dialog box or as a standalone function like the Input box.
It would be nice to have this built into MS in a Dialog box or as a standalone function like the Input box.
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
There is a date picker/calendar utility that I have used for years. It may not have the interface you want, but you can check it out.
TClockEx is freeware, available at: http://www.rcis.co.za/dale/tclockex/
TClockEx is freeware, available at: http://www.rcis.co.za/dale/tclockex/
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!
Bob
A humble man and PROUD of it!
Date Picker
Bob,
Thanks for the link, nifty little progam there but not what I had in mind. I just want to bring up a calendar, allow the user to go forward and backward and select a date.
Currently the user has to enter the date manually, and as you now different people enter them differently 01/01/2007, 01/01/07, 1/1/07 etc. If I had a calendar/date picker they would all be in the the same format. So, I quess you could say I am just looking for consistancy in the format.
Any other ideas?
Thanks for the link, nifty little progam there but not what I had in mind. I just want to bring up a calendar, allow the user to go forward and backward and select a date.
Currently the user has to enter the date manually, and as you now different people enter them differently 01/01/2007, 01/01/07, 1/1/07 etc. If I had a calendar/date picker they would all be in the the same format. So, I quess you could say I am just looking for consistancy in the format.
Any other ideas?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
How about this little custom dialog I just knocked up. This code creates a "Date Picker" dialog. You could have a button on your dialog run this code. You then have the date the user selected in nDay, nMon and nYear.
Paste the code into a new macro and run it to test it out. Will display the date you selected.
Code: Select all
VBSTART
VBEND
Dialog>dlgDatePicker
Caption=Date Picker
Width=303
Height=290
Top=225
Left=172
Min=0
Max=0
Resize=0
Button=x,16,72,17,25,10
Button=x,56,72,17,25,11
Button=x,96,72,17,25,12
Button=x,136,72,17,25,13
Button=x,176,72,17,25,14
Button=x,216,72,17,25,15
Button=x,256,72,17,25,16
Button=x,16,104,17,25,17
Button=x,56,104,17,25,18
Button=x,96,104,17,25,19
Button=x,136,104,17,25,20
Button=x,176,104,17,25,21
Button=x,216,104,17,25,22
Button=x,256,104,17,25,23
Button=x,16,136,17,25,24
Button=x,56,136,17,25,25
Button=x,96,136,17,25,26
Button=x,136,136,17,25,27
Button=x,176,136,17,25,28
Button=x,216,136,17,25,29
Button=x,256,136,17,25,30
Button=x,16,168,17,25,31
Button=x,56,168,17,25,32
Button=x,96,168,17,25,33
Button=x,136,168,17,25,34
Button=x,176,168,17,25,35
Button=x,216,168,17,25,36
Button=x,256,168,17,25,37
Button=x,16,200,17,25,38
Button=x,56,200,17,25,39
Button=x,96,200,17,25,40
Button=x,136,200,17,25,41
Button=x,176,200,17,25,42
Button=x,216,200,17,25,43
Button=x,256,200,17,25,44
Button=x,16,234,17,25,45
Button=x,56,234,17,25,46
Button=x,96,234,17,25,47
Button=x,136,234,17,25,48
Button=x,176,234,17,25,49
Button=x,216,234,17,25,50
Button=x,256,234,17,25,51
Button=->,240,16,33,25,502
Button=<-,16,16,33,25,501
Edit=txtYear,160,16,65,
Edit=txtMonth,64,16,89,
Label=M ,16,48,true
Label=T ,56,48,true
Label=W ,96,48,true
Label=Th,136,48,true
Label=F,176,48,true
Label=Sa,216,48,true
Label=Su,256,48,true
EndDialog>dlgDatePicker
//Define month name array
Let>mName[1]=January
Let>mName[2]=February
Let>mName[3]=March
Let>mName[4]=April
Let>mName[5]=May
Let>mName[6]=June
Let>mName[7]=July
Let>mName[8]=August
Let>mName[9]=September
Let>mName[10]=October
Let>mName[11]=November
Let>mName[12]=December
//Initialise
Year>nYear
Month>nMon
Let>nMon=nMon-0
Show>dlgDatePicker
GoSub>ResetButtons
Label>dpLoop
GetDialogAction>dlgDatePicker,r
If>r=501
Let>nMon=nMon-1
If>nMon=0
Let>nYear=nYear-1
Let>nMon=12
Endif
GoSub>ResetButtons
Endif
If>r=502
Let>nMon=nMon+1
If>nMon=13
Let>nYear=nYear+1
Let>nMon=1
Endif
GoSub>ResetButtons
Endif
If>r=2
//User cancelled
Let>cancelled=TRUE
Goto>allDone
Endif
If>{(%r% > 9) AND (%r% < 67)}
//A day button was clicked
Let>ndx=r-10
Let>daySelected=dlgDatePicker.msButton%ndx%
If>daySelected<>x
Let>nDay=daySelected
Let>cancelled=FALSE
Goto>allDone
Endif
Endif
Wait>0.3
Goto>dpLoop
Label>allDone
If>cancelled=FALSE
MessageModal>User selected day %nDay% of Month %nMon% of Year %nYear%
Else
MessageModal>User Cancelled
Endif
SRT>ResetButtons
Let>dlgDatePicker.txtYear=%nYear%
Let>txtMonth=mName[%nMon%]
Let>dlgDatePicker.txtMonth=%txtMonth%
//what day does the 1st of nMon fall on?
VBEval>WeekDay(DateSerial(%nYear%,%nMon%,1)),nDay1
//how many days in month
VBEval>Day(DateAdd("d", -1, DateAdd("m", 1, "%nYear% - %nMon% -1"))),NumDays
//blank out all buttons
Let>k=0
Repeat>k
Let>dlgDatePicker.msButton%k%=x
Let>k=k+1
Until>k=40
//If starts on Sunday
If>nDay1=1
Let>nDay1=8
Endif
//Set day numbers on appropriate buttons
Let>NumDays=NumDays+1
Let>btnStart=nDay1-2
Let>k=btnStart
Let>d=1
Repeat>d
Let>dlgDatePicker.msButton%k%=%d%
Let>k=k+1
Let>d=d+1
Until>d=NumDays
//Reset and redraw dialog
ResetDialogAction>dlgDatePicker
End>ResetButtons
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Date Picker for MS
Marcus,
Thank you, works great
Thank you, works great
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Here's a version which hides the unused buttons. Much neater:
BTW - I seem to have discovered a bug here with the button handle variables and the way they are numbered. Don't seem to match the numbering of the button names. The above works around it. Will get that looked at for a future update. Until then the above works fine.
Code: Select all
VBSTART
VBEND
Dialog>dlgDatePicker
Caption=Date Picker
Width=303
Height=290
Top=225
Left=172
Min=0
Max=0
Resize=0
Button=x,16,72,17,25,10
Button=x,56,72,17,25,11
Button=x,96,72,17,25,12
Button=x,136,72,17,25,13
Button=x,176,72,17,25,14
Button=x,216,72,17,25,15
Button=x,256,72,17,25,16
Button=x,16,104,17,25,17
Button=x,56,104,17,25,18
Button=x,96,104,17,25,19
Button=x,136,104,17,25,20
Button=x,176,104,17,25,21
Button=x,216,104,17,25,22
Button=x,256,104,17,25,23
Button=x,16,136,17,25,24
Button=x,56,136,17,25,25
Button=x,96,136,17,25,26
Button=x,136,136,17,25,27
Button=x,176,136,17,25,28
Button=x,216,136,17,25,29
Button=x,256,136,17,25,30
Button=x,16,168,17,25,31
Button=x,56,168,17,25,32
Button=x,96,168,17,25,33
Button=x,136,168,17,25,34
Button=x,176,168,17,25,35
Button=x,216,168,17,25,36
Button=x,256,168,17,25,37
Button=x,16,200,17,25,38
Button=x,56,200,17,25,39
Button=x,96,200,17,25,40
Button=x,136,200,17,25,41
Button=x,176,200,17,25,42
Button=x,216,200,17,25,43
Button=x,256,200,17,25,44
Button=x,16,234,17,25,45
Button=x,56,234,17,25,46
Button=x,96,234,17,25,47
Button=x,136,234,17,25,48
Button=x,176,234,17,25,49
Button=x,216,234,17,25,50
Button=x,256,234,17,25,51
Button=->,240,16,33,25,502
Button=<-,16,16,33,25,501
Edit=txtYear,160,16,65,
Edit=txtMonth,64,16,89,
Label=M ,16,48,true
Label=T ,56,48,true
Label=W ,96,48,true
Label=Th,136,48,true
Label=F,176,48,true
Label=Sa,216,48,true
Label=Su,256,48,true
EndDialog>dlgDatePicker
//Define month name array
Let>mName[1]=January
Let>mName[2]=February
Let>mName[3]=March
Let>mName[4]=April
Let>mName[5]=May
Let>mName[6]=June
Let>mName[7]=July
Let>mName[8]=August
Let>mName[9]=September
Let>mName[10]=October
Let>mName[11]=November
Let>mName[12]=December
//Initialise
Year>nYear
Month>nMon
Let>nMon=nMon-0
Show>dlgDatePicker
GoSub>ResetButtons
Label>dpLoop
GetDialogAction>dlgDatePicker,r
If>r=501
Let>nMon=nMon-1
If>nMon=0
Let>nYear=nYear-1
Let>nMon=12
Endif
GoSub>ResetButtons
Endif
If>r=502
Let>nMon=nMon+1
If>nMon=13
Let>nYear=nYear+1
Let>nMon=1
Endif
GoSub>ResetButtons
Endif
If>r=2
//User cancelled
Let>cancelled=TRUE
Goto>allDone
Endif
If>{(%r% > 9) AND (%r% < 67)}
//A day button was clicked
Let>ndx=r-10
Let>daySelected=dlgDatePicker.msButton%ndx%
If>daySelected<>x
Let>nDay=daySelected
Let>cancelled=FALSE
Goto>allDone
Endif
Endif
Wait>0.02
Goto>dpLoop
Label>allDone
If>cancelled=FALSE
MessageModal>User selected day %nDay% of Month %nMon% of Year %nYear%
Else
MessageModal>User Cancelled
Endif
SRT>ResetButtons
Let>dlgDatePicker.txtYear=%nYear%
Let>txtMonth=mName[%nMon%]
Let>dlgDatePicker.txtMonth=%txtMonth%
//what day does the 1st of nMon fall on?
VBEval>WeekDay(DateSerial(%nYear%,%nMon%,1)),nDay1
//how many days in month
VBEval>Day(DateAdd("d", -1, DateAdd("m", 1, "%nYear% - %nMon% -1"))),NumDays
//blank out all buttons
Let>k=0
Repeat>k
Let>dlgDatePicker.msButton%k%=x
Let>h=k
//work around handle numbering bug in older 9.1 versions
If>MSCHED_VER<9.1.04
Let>h=h+1
Endif
Let>thisHwnd=dlgDatePicker.msButton%h%.Handle
LibFunc>User32,ShowWindow,r,thisHwnd,0
Let>k=k+1
Until>k=42
//If starts on Sunday
If>nDay1=1
Let>nDay1=8
Endif
//Set day numbers on appropriate buttons
Let>NumDays=NumDays+1
Let>btnStart=nDay1-2
Let>k=btnStart
Let>d=1
Repeat>d
Let>dlgDatePicker.msButton%k%=%d%
Let>h=k
//work around handle numbering bug in older 9.1 versions
If>MSCHED_VER<9.1.04
Let>h=h+1
Endif
Let>thisHwnd=dlgDatePicker.msButton%h%.Handle
LibFunc>User32,ShowWindow,r,thisHwnd,1
Let>k=k+1
Let>d=d+1
Until>d=NumDays
//Reset and redraw dialog
ResetDialogAction>dlgDatePicker
End>ResetButtons
Last edited by Marcus Tettmar on Thu Aug 30, 2007 11:33 am, edited 1 time in total.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Ed,
Presumably Tony needs the user to enter a date which is not necessarily today's date.
Presumably Tony needs the user to enter a date which is not necessarily today's date.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
>I guess I am more interested in the business process that
>might require an end user to match a date and a time of day
>for that chosen date.
Not sure what you mean by that.
Tony just wants a way for a user to CHOOSE a date. I can think of plenty of reasons for doing that. Our reporting tool for example, asks me to choose a start and end date for the reporting period.
The point is that using a free format field for the user to enter the date is problematic since you can't guarantee that the user will use the same format you are expecting. You'd then have to validate the input. What if the user's regional settings use mm/dd/yyyy and you're expecting dd/mm/yyyy? One obvious solution is to use a dialog that has three fields for each date MM-DD-YYYY. So the user enters each part in three fields making up one date. You would still need to test that the user entered the right number of days for the month, and didn't enter alphas, or that the right number of digits were used for the month and year etc.
Using a Date Picker like the dialog I posted removes ALL these problems. Since the user can only click a button. Once he's done that you have the date and there is no ambiguity, and no need for input validation.
>might require an end user to match a date and a time of day
>for that chosen date.
Not sure what you mean by that.
Tony just wants a way for a user to CHOOSE a date. I can think of plenty of reasons for doing that. Our reporting tool for example, asks me to choose a start and end date for the reporting period.
The point is that using a free format field for the user to enter the date is problematic since you can't guarantee that the user will use the same format you are expecting. You'd then have to validate the input. What if the user's regional settings use mm/dd/yyyy and you're expecting dd/mm/yyyy? One obvious solution is to use a dialog that has three fields for each date MM-DD-YYYY. So the user enters each part in three fields making up one date. You would still need to test that the user entered the right number of days for the month, and didn't enter alphas, or that the right number of digits were used for the month and year etc.
Using a Date Picker like the dialog I posted removes ALL these problems. Since the user can only click a button. Once he's done that you have the date and there is no ambiguity, and no need for input validation.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?