[RESOLVED] increasing monthview's days
I have the current date displayed in a label. That current date is supplied by the monthview control when the program starts. Now the user of the program will want to look at previous and future days/dates. For this I have two buttons which decrease or increase the day by only one day. But the following code doesn't work. And after searching around I could only find examples where the user clicks on the monthview control and I couldn't work it out. So does anyone know how to do this? Thanks.
Increase:
Code:
label.Caption = Format(calendar.Value + 1, "dddd d MMM yyyy")
Decrease:
Code:
label.Caption = Format(calendar.Value - 1, "dddd d MMM yyyy")
Re: increasing monthview's days
I'm a little confused - if you have calendar type (the monthview) control on your form why do you need another control (buttons) to change its value?
How is not enough to simply let your users select date directly on the calendar?
Instead of monthview you can also use DateTimePicker control.
In case you still want to use buttons you need to change calendar's value first and DateAdd() function comes handy:
Code:
MonthView1.Value = DateAdd("d", 1, MonthView1.Value) 'or -1
'you may now assign caption to label control as you already do
Re: increasing monthview's days
Thanks RhinoBull that works well. I know what you mean about clicking on the control but I went with this way because I reckon there'll be less chance of error or mistakes when I consider the computer knowledge of the user. Nice work, thanks again.