dater12 wrote:
You have 2 problems that I see. First you are referencing the control with the incorrect associated variable name.
Code:
GuiControl,, vmocal, %yr%0101-%yr%1231
; should be
GuiControl,, mocal, %yr%0101-%yr%1231
Aha!! Thanks for this, dater12! I hadn't used GuiControl before, and couldn't see the lack of v in the examples. GUI needs the v, GuiControl doesn't.
Quote:
Second, you cannot perform 'normal' math operations on date-time variables, they are not 'normal' numbers.
The StringSplit converted the dates to strings, and henceforth to normal numbers. That stuff mostly worked, once I fixed the first problem, just had to tweak the calculations a bit. Oh, and to use // instead of / to get an integer result.
Here's the code that does what I want.
Code:
yr := A_YYYY
GUI, Destroy
yrspan = %yr%0101-%yr%0101
; Gui, Add, MonthCal, W-4 R3 Multi vmocal, %yrspan%
Gui, Add, MonthCal, W-4 R3 Multi vmocal
Gui, Add, Button, Section, &Previous Year
Gui, Add, Button, ys, &Next Year
GuiControl,, mocal, %yrspan%
GuiControl,, mocal, %A_Now%
Gui, Show, Autosize X20 yCenter
return
ButtonPreviousYear:
Gui, Submit, NoHide
StringSplit, Date, mocal, -
Date1 := Date1 - 10000
Date2 := Date2 - 10000
yrspan = %Date1%-%Date2%
yr := Date1 // 10000
GuiControl,, mocal, %yr%0101-%yr%0101
GuiControl,, mocal, %yrspan%
Gui, Show
return
ButtonNextYear:
Gui, Submit, NoHide
; yr := yr + 1
; yrspan = %yr%0101-%yr%1231
StringSplit, Date, mocal, -
Date1 := Date1 + 10000
Date2 := Date2 + 10000
yrspan = %Date1%-%Date2%
yr := Date1 // 10000
GuiControl,, mocal, %yr%1231-%yr%1231
GuiControl,, mocal, %yrspan%
Gui, Show
return
GuiClose:
ExitApp
Now I can write the rest of the application, now that I have the calendar interface under control. Thanks again. And thanks to Nick for responding also, although I didn't make clear that I wanted to move the year of the selection along with the year displayed.