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 for previous button getMonth(-z) z = z + 1 w = w + 1
'Code for next button getMonth(z) z = z + 1 w = w + 1
'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


Reply






MultiQuote






|