Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 22nd, 2004, 11:13 AM
Authorized User
 
Join Date: Aug 2004
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Arsi
Default 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;
                        }
                    }
                }
            }
        }

*******(*)*******
__________________
*******(*)*******
 
Old October 22nd, 2004, 04:13 PM
Authorized User
 
Join Date: Aug 2004
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Arsi
Default

Nevermind...I was able to figure it out. I was not allocating enough memory locations for the array strSort[]. Thank you.

*******(*)*******





Similar Threads
Thread Thread Starter Forum Replies Last Post
array displaying as image vinodkokane Visual C++ 1 April 23rd, 2007 12:06 AM
Trouble displaying DetailsView & FormView Sheri B ASP.NET 2.0 Basics 0 November 11th, 2006 04:08 PM
Trouble displaying Data Grid control bam1934 ASP.NET 1.0 and 1.1 Basics 4 May 25th, 2005 07:59 AM
trouble creating array Tachyon Beginning PHP 3 June 28th, 2004 11:25 AM
Having trouble displaying txt doc on WinForm tpsmith78 VS.NET 2002/2003 1 January 22nd, 2004 12:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.