Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 150,071 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,800 people online right now. Registration is fast and FREE... Join Now!




Custom Calendar Control

 
Reply to this topicStart new topic

Custom Calendar Control

quakeworld2007
1 Mar, 2008 - 08:45 PM
Post #1

New D.I.C Head
*

Joined: 28 Sep, 2007
Posts: 44


My Contributions
I have created a datagrid calendar that first loads the current month. It has two buttons that can be selected one for the previous month and the other for the next month.

My problem is that these buttons only work if just one of them is clicked when the program is running. I can not figure out the logic to get it to work if someone wants to hit previous and then the next button.

CODE


'Code for previous button

        getMonth(-z)

        z = z + 1
        w = w + 1



CODE


'Code for next button

    getMonth(z)

        z = z + 1
        w = w + 1



CODE


'Getmonth

currentmonth = Date.Today.AddMonths(direction)
        theDay = Format(currentmonth, "dd")
        totalDayLastMnth = Date.DaysInMonth(currentmonth.Year, currentmonth.Month)

        lastMnthDay = currentmonth.AddDays(-1)
        fday = lastMnthDay.AddDays(1)

        dayWeekLDay = lastMnthDay.DayOfWeek

        If dayWeekLDay = 6 Then

            FormatMonth(fday.Month)
            Label1.Text = thismonth & " " & fday.Year

            Dim xRow As Integer = 0
            Dim yColumn As Integer = 0
            Dim i As Integer = 1

            While xRow < DataGridView1.Rows.Count And i < totalDayLastMnth

                While yColumn < DataGridView1.Columns.Count

                    If i > totalDayLastMnth Then


                        Return

                    End If

                    Me.DataGridView1.Rows(xRow).Cells(yColumn).Value = lastMnthDay.AddDays(i).Day

                    yColumn = yColumn + 1
                    i = i + 1

                End While

                xRow = xRow + 1
                yColumn = 0

            End While

        Else

            FormatMonth(fday.Month)
            Label1.Text = thismonth & " " & fday.Year

            Dim xRow As Integer = 0
            Dim yColumn As Integer = dayWeekLDay + 1
            Dim i As Integer = 1

            While xRow < DataGridView1.Rows.Count And i < totalDayLastMnth

                While yColumn < DataGridView1.Columns.Count

                    If i > totalDayLastMnth Then

                        Return

                    End If

                    Me.DataGridView1.Rows(xRow).Cells(yColumn).Value = lastMnthDay.AddDays(i).Day

                    yColumn = yColumn + 1
                    i = i + 1

                End While

                xRow = xRow + 1
                yColumn = 0

            End While

        End If



User is offlineProfile CardPM
+Quote Post

quakeworld2007
RE: Custom Calendar Control
1 Mar, 2008 - 09:22 PM
Post #2

New D.I.C Head
*

Joined: 28 Sep, 2007
Posts: 44


My Contributions
Solved it, I was making it way to hard to work with.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 11:01PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month