Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get month value immediately when the month in calendar control changes

Status
Not open for further replies.

gorcib

Technical User
May 11, 2004
12
SI
Hi!

I would like to get the value of currently selected or changed month just by clicking the month combobox in calendar control in VB6.

I have the following code but it seems it doesn't work (the value it returns is always zero.

[tt]Private Sub calKoledar_NewMonth()
Dim intMonth As Integer
intMonth = calKoledar.Month
MsgBox "new month " & intMonth
End Sub[/tt]
 
The Calendar control has often been found to be flakey in VB. Use the Monthview control or the DateTimePicker control instead.

To get the month number, use the Month function, which returns the month number from a Date value:

MsgBox Month(MonthView1.Value)

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
I tried to used that first but I just could get the control in the control toolbox. I think I checked the righ library or OCX file in projec reference, but the control does not appear.

Thanks a lot in advance!
 
Look for Microsoft Windows Common Controls 2 (6.0), which contains the DateTimePicker control and the Monthview control. Go to Project|Components rather than References. You will find the file ref is MSCOMCT2.OCX

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Now I have managed to use MonthView control but still it is not satisfactory enough. There is no event like MonthChanged. I'd like that when I select month there wouldn't be necessary to clik on any day of month to get the month index.

regards,
zabig
 
this worked for me. It returns the month number.
Code:
Private Sub MonthView_Click()
    MsgBox MonthView.Month
End Sub

Sam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top