ntahir
asked on
Calendar
I am trying to develop a calendar with atleast the subsequent month showing on the form. What I want to do is that when the application is run the current date is
highlighted and the subsequent meaning the next month
should show on the form or perhaps it should say next month on the command button and should show the next month. I have written the code in which when I run the application I have to input the the month and the year to see the month. The code which I wrote is as follows but I need some suggestions to incorporate what I want to do as I wrote earlier:
Dim sFirstDate As String
Dim nMonth As Integer
Dim nYear As Integer
Dim dtPresentDate As String
Dim nI As Integer
'Dim DayOfMonth As Variant
Private Sub Combo1_Click()
CleanDays
PopulateMonth
End Sub
Private Sub Command1_Click()
End Sub
Private Sub Form_Load()
AddMonths
End Sub
Private Sub UpDown1_DownClick()
If (Text2 < 9999) Then
Text2 = Text2 - 1
End If
End Sub
Private Sub UpDown1_UpClick()
If (Text2 > 0) Then
Text2 = Text2 + 1
End If
End Sub
Public Sub AddMonths()
Combo1.AddItem "January"
Combo1.ItemData(Combo1.New Index) = 1
Combo1.AddItem "February"
Combo1.ItemData(Combo1.New Index) = 2
Combo1.AddItem "March"
Combo1.ItemData(Combo1.New Index) = 3
Combo1.AddItem "April"
Combo1.ItemData(Combo1.New Index) = 4
Combo1.AddItem "May"
Combo1.ItemData(Combo1.New Index) = 5
Combo1.AddItem "June"
Combo1.ItemData(Combo1.New Index) = 6
Combo1.AddItem "July"
Combo1.ItemData(Combo1.New Index) = 7
Combo1.AddItem "August"
Combo1.ItemData(Combo1.New Index) = 8
Combo1.AddItem "September"
Combo1.ItemData(Combo1.New Index) = 9
Combo1.AddItem "October"
Combo1.ItemData(Combo1.New Index) = 10
Combo1.AddItem "November"
Combo1.ItemData(Combo1.New Index) = 11
Combo1.AddItem "December"
Combo1.ItemData(Combo1.New Index) = 12
End Sub
Public Sub CleanDays()
For nI = 0 To 41
Text1(nI) = ""
Next nI
End Sub
Public Sub PopulateMonth()
CleanDays
nMonth = Combo1.ItemData(Combo1.Lis tIndex)
nYear = Text2.Text
sFirstDate = nMonth & "/01" & "/" & nYear
DayOfMonth = WeekDay(sFirstDate)
For nI = DayOfMonth To 42
dtPresentDate = nMonth & "/" & nI - DayOfMonth + 1 & "/" & nYear
If (IsDate(dtPresentDate)) Then
Text1(nI - 1) = nI - DayOfMonth + 1
End If
Next nI
End Sub
Naeem Tahir (ntahir)
nt7471@aol.com
highlighted and the subsequent meaning the next month
should show on the form or perhaps it should say next month on the command button and should show the next month. I have written the code in which when I run the application I have to input the the month and the year to see the month. The code which I wrote is as follows but I need some suggestions to incorporate what I want to do as I wrote earlier:
Dim sFirstDate As String
Dim nMonth As Integer
Dim nYear As Integer
Dim dtPresentDate As String
Dim nI As Integer
'Dim DayOfMonth As Variant
Private Sub Combo1_Click()
CleanDays
PopulateMonth
End Sub
Private Sub Command1_Click()
End Sub
Private Sub Form_Load()
AddMonths
End Sub
Private Sub UpDown1_DownClick()
If (Text2 < 9999) Then
Text2 = Text2 - 1
End If
End Sub
Private Sub UpDown1_UpClick()
If (Text2 > 0) Then
Text2 = Text2 + 1
End If
End Sub
Public Sub AddMonths()
Combo1.AddItem "January"
Combo1.ItemData(Combo1.New
Combo1.AddItem "February"
Combo1.ItemData(Combo1.New
Combo1.AddItem "March"
Combo1.ItemData(Combo1.New
Combo1.AddItem "April"
Combo1.ItemData(Combo1.New
Combo1.AddItem "May"
Combo1.ItemData(Combo1.New
Combo1.AddItem "June"
Combo1.ItemData(Combo1.New
Combo1.AddItem "July"
Combo1.ItemData(Combo1.New
Combo1.AddItem "August"
Combo1.ItemData(Combo1.New
Combo1.AddItem "September"
Combo1.ItemData(Combo1.New
Combo1.AddItem "October"
Combo1.ItemData(Combo1.New
Combo1.AddItem "November"
Combo1.ItemData(Combo1.New
Combo1.AddItem "December"
Combo1.ItemData(Combo1.New
End Sub
Public Sub CleanDays()
For nI = 0 To 41
Text1(nI) = ""
Next nI
End Sub
Public Sub PopulateMonth()
CleanDays
nMonth = Combo1.ItemData(Combo1.Lis
nYear = Text2.Text
sFirstDate = nMonth & "/01" & "/" & nYear
DayOfMonth = WeekDay(sFirstDate)
For nI = DayOfMonth To 42
dtPresentDate = nMonth & "/" & nI - DayOfMonth + 1 & "/" & nYear
If (IsDate(dtPresentDate)) Then
Text1(nI - 1) = nI - DayOfMonth + 1
End If
Next nI
End Sub
Naeem Tahir (ntahir)
nt7471@aol.com
Use the Microsoft Calendar control. Your users will thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
A: automatically show the current month when this form is opened
B: have the current day be in the top row and show the next 30 to 40 dates regardless of the month
C: have a button that advances the calendar one month at a time
D: something else entirely
please bring some clarity into this situation ;-)