John Smith

John Smith

  • NA
  • 8
  • 6.1k

Updating Local Function to Global

Sep 6 2010 6:28 PM
Hi,

i'm having problems with updating a local function to global, the reason i'm using a local function and not public string (outside the function but in the class) is that it doesn't update the string after function exists therefore keeping it local.

i am reading from a file using Text.FileReader and when a user clicks the button it gets the file which is a word document converted to a text document using the Object Word Libary 9/10/11 (not 12, as Word.Document/Application doesn't seem to work) and gets the date which is in the file and puts it in a string.

that string works fine, has the date located inside it when the file is read and works...  here is a piece of code i am trying to get to work and i'm not getting much success.

Not Working:

 
            DateTime dt = new DateTime(textIssueDate); // textIssueDate contains 20 May 2010, but is a variable


Working:


          
 DateTime dt = new DateTime(2001, 01, 01);


Yeah... different format DD, MMM, YYYY

Should be working:

string Day;
string Month;
string Year;

textIssueDate = Day.Substring(0, 2);
textIssueDate = Month.Substring(1, 3);
textIssueDate = Year.Substring(2, 4);

int.Parse(Day);
int.Parse(Month);
int.Parse(Year);

DateTime dt = new DateTime(Day, Month, Year);

Should be working code should be working :P, datetime accepts int's but for some reason says i have not converted the string to int when i clearly have with int.parse.

Below is the code that i want it to work in (using MonthlyCalender to set the date)


         public void clndIssueDate_DateChanged(object sender, DateRangeEventArgs e)
        {
                 DateTime dt = new DateTime(textIssueDate); // textIssueDate contains 20 May 2010
        }



When i try to use the code above, i ofcourse get null.

I also tried Day, Month, Year Substrings of textIssueDate with no success.

Basically is there a way to update a local string after it has been used (or accessed) and set it to public.

P.S my code probaly needs fixing but for the moment it works

P.S.S this program is (hopefully) client-side only program to keep track of my assignments and progress etc.




Attachment: Code.rar

Answers (2)