Skip to content

Updating Local Function to Global

John Smith

Asked Sep 6, 2010, 2:28 PM EDT2 answers
Share
LinkedInX
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:

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


Working:

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


Yeah... different format DD, MMM, YYYY

Should be working:

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


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

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Suthish Nair
    0
    Migth converting to required format will help..
    Convert.ToDateTime(textIssueDate).ToString("dd-MMM-yyyy")
    0
  • 0
    Didn't fix my problem (and i already tryed that but i tryed it that way and it does help)

    I'll try and fix it by myself so i learn, else i'll come back and post.

    Thanks for the reply.
    0