Can't get date value

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamilou
    New Member
    • Nov 2011
    • 1

    #1

    Can't get date value

    Hi,
    I'm new to programmimg and to C sharp.
    I'm trying to make my application return a date string but i'm not able to do so.
    When i use a different kind of data (a regular variable instead of the date variable) , it works.
    here's the code :

    RatingModel RM = MM.Customer.Rat ingModel;
    ArrayList Result = new ArrayList();
    bool Alerte = false;
    Calc compte = MM.PM("OPENING_ PRINCIPAL", null) as Calc;
    Calc ETATF = MM.PM("STMT_DAT E", null) as Calc;

    for (int x=0; x<compte.Count ; x++)
    {
    if ((compte[x] != 1) && (compte[x] != 2))
    {
    Result.Add(true );
    Result.Add(ETAT F[x]);
    }
    }
    MacroValue = Result;
    }
    ------------------
    The variable that return the code is 'STMT_DATE'. when i use antoher variable everything works fine.

    here is the error message :
    ------------
    System.NullRefe renceException: Object reference not set to an instance of an object.
    at FinancialAnalys t.conditions_ca bc671c602f420cb 308d2caa1de1093 .CondExecute(In t32 FormulaID, FormulaEvaluato r FE, MacrosModule MM)
    at MKMV.RiskAnalys t.Ratings.Modul es.Macros.Ratin gsMacros.RunMod elConditions(In t32 Type, Boolean StopAtFirstFail )
    ------------

    Thank you very much !
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    What line is this occurring on? You're getting a very clear null reference exception, but none of the lines in the stack trace are in your code so something is likely wrong in your MM.PM method.

    Comment

    • xunter
      New Member
      • Nov 2011
      • 7

      #3
      Originally posted by GaryTexmo
      What line is this occurring on? You're getting a very clear null reference exception, but none of the lines in the stack trace are in your code so something is likely wrong in your MM.PM method.
      I think that the line is here:

      Result.Add(ETAT F[x]);

      jamilou, You should write like below:

      if (ETATF != null)
      {
      Result.Add(ETAT F[x]);
      }
      else
      {
      // do something else
      }

      Comment

      Working...