Month Calendar BOlded Dates range

dashley

Well-known member
Joined
May 27, 2005
Messages
59
Location
Tennessee
Programming Experience
10+
HI,

VB.NET:
[COLOR=blue][SIZE=2]Me.MonthCalendar1.BoldedDates = New System.DateTime() _[/SIZE][SIZE=2] {New System.DateTime(2006, 7, 15, 0, 0, 0, 0), _
[/SIZE][/COLOR][SIZE=2][/SIZE][SIZE=2][COLOR=blue]New System.DateTime(2006, 7, 30, 0, 0, 0, 0)}[/COLOR][/SIZE]

I'm trying to figure out how to take the above statement and populate it with a range of dates at runtime (Say 2 aug till 18 aug) from a database selection. I can get the data with no probelm and loop through it but thats where I run into my delima.

Thanks




 
Disreagard. I went without the array


VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Connstr [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#800000]"Data Source=MSSQL1;Server=MyServer;Database=mydb;Uid=myuid;Pwd=****;"
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] conn [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlConnection(Connstr)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] DR1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] SqlDataReader
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] SqlStr [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]String
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] CMD1 [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlCommand
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Diff [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] I [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] DTE [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Date
[/COLOR][/SIZE][SIZE=2]SqlStr = [/SIZE][SIZE=2][COLOR=#800000]"Select StartDate, enddate from schedules where scheduleid=35"
[/COLOR][/SIZE][SIZE=2]CMD1.CommandText = SqlStr
CMD1.Connection = conn
conn.Open()
DR1 = CMD1.ExecuteReader
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] Startdate [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Date
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] EndDate [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Date
 
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]While[/COLOR][/SIZE][SIZE=2] DR1.Read
Startdate = DR1([/SIZE][SIZE=2][COLOR=#800000]"Startdate"[/COLOR][/SIZE][SIZE=2])
EndDate = DR1([/SIZE][SIZE=2][COLOR=#800000]"Enddate"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]While
[/COLOR][/SIZE][SIZE=2]Diff = DateDiff(DateInterval.DayOfYear, Startdate, EndDate)
[/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] I = 1 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] Diff
DTE = DateAdd(DateInterval.Day, I, Startdate)
ListBox1.Items.Add(DTE)
MonthCalendar1.AddBoldedDate(Convert.ToDateTime(DTE))
[/SIZE][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=2]MonthCalendar1.UpdateBoldedDates()
[/SIZE]
 
Back
Top