Turn your Mobile Apps into m-commerce apps – Learn More!

You're Browsing As A Guest! Register Now...
Become a VB.NET Expert!

Join 416,729 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 2,940 people online right now.Registration is fast and FREE... Join Now!



Page 1 of 1
  • You cannot start a new topic
  • Reply Reply

Custom Calendar Control Rate Topic: -----

#1 quakeworld2007  Icon User is offline

  • D.I.C Head
  • PipPip

Reputation: 3
  • View blog
  • Posts: 70
  • Joined: 28-September 07


Dream Kudos: 0

Share |

Custom Calendar Control

Post icon  Posted 01 March 2008 - 08:45 PM

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 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



Was This Post Helpful? 0
  • +
  • -


#2 quakeworld2007  Icon User is offline

  • D.I.C Head
  • PipPip

Reputation: 3
  • View blog
  • Posts: 70
  • Joined: 28-September 07


Dream Kudos: 0

Re: Custom Calendar Control

Posted 01 March 2008 - 09:22 PM

Solved it, I was making it way to hard to work with.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1
  • You cannot start a new topic
  • Reply Reply


Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users