trouble displaying data from array
Hello,
If anyone can help me, I would appreciate it. I am trying to display the values of an array strWkEnd[] into Excel cells, but it is only displaying part of the data. It doesn't display 5 years worth of data. Array intYear[] contains the years 2004-2030 and strMonths[] contains the months 01-12. It is supposed to be locating and displaying the weekend dates of every month of every year from 2004-2030, but it only displays the data for the years 2004-2025. Can anyone tell me what I'm doing wrong? I think the problem is with the for loops...Please help me.
private void WeekEnd()
{
int i;
int j;
int k = 1;
int m = 0;
int h = 1;
int l = 324;
for (i = 0; i < 27; i++)
{
for (j = 0; j < 12; j++)
{
intDaysInMonth = DateTime.DaysInMonth(intYear[i], Convert.ToInt32(strMonths[j]));
for (k = 1; k <= intDaysInMonth; k++)
{
DateTime dt = new DateTime(intYear[i], Convert.ToInt32(strMonths[j]), k);
if (dt.DayOfWeek.ToString() == DayOfWeek.Sunday.ToString())
{
strWkEnd[m] = strMonths[j].ToString() + "/" + k.ToString() + "/" + intYear[i].ToString();
strSort[l] = strMonths[j].ToString() + k.ToString() + intYear[i].ToString();
xlSheet = (Excel.Worksheet)ThisApplication.Worksheets["Sheet1"];
xlSheet.Cells[h,7] = strWkEnd[m].ToString();
l = l + 1;
h = h + 1;
m = m + 1;
}
}
}
}
}
*******(*)*******
__________________
*******(*)*******
|