You must Sign In to post a response.
  • Category: ASP.NET

    How to increase the value in a every month using for loop

    i want to increase every month sick value is 0.5
    jan value= 0.5
    feb=1
    mah=1.5
    now this month is march means
    sick =1.5
    Any body can help me......
  • #756053
    Could you explain how you need on for loop?

  • #756054
    Hi..
    Can u explain without for loop how can i do this...

  • #756060
    hi

    int mthvalue = DateTime.Now.Month;

    if (mthvalue==yourvalue)
    {

    }

    Name : Dotnet Developer-2015
    Email Id : kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #756077
    Try to use static class with constants declared for every month as shown below:
    public static class MonthEnum{
    public const float Jan= 0.5;
    public const float Feb= 1.0;
    public const float Mar= 1.5;
    public const float Apr= 2.0;
    public const float May= 2.5;
    public const float Jun = 3.0;
    public const float Jul= 3.5;
    public const float Aug= 40;
    public const float Sept= 4.5;
    public const float Oct = 5.0;
    public const float Nov= 5.5;
    public const float Dec= 6.0;

    }

    Miss. Jain
    Microsoft Certified Technology Specialist in .Net

  • #760938
    hi
    ancy

    You can try this code for your output


    string month = DateTime.Now.ToString("MMMM");

    decimal Incrementval;

    double tmp = 0.5;
    decimal current = (decimal)tmp ;

    if (month == "January") { Incrementval = current; }
    if (month == "Feb") { Incrementval = current+0.5M; }
    if (month == "March") { Incrementval = current + 0.5M; }
    if (month == "April") { Incrementval = current + 0.5M; }
    if (month == "May") { Incrementval = current + 0.5M; }
    if (month == "June") { Incrementval = current + 0.5M; }
    if (month == "July") { Incrementval = current + 0.5M; }
    if (month == "Aug") { Incrementval = current + 0.5M; }
    if (month == "Sep") { Incrementval = current + 0.5M; }
    if (month == "Oct") { Incrementval = current + 0.5M; }
    if (month == "Nov") { Incrementval = current + 0.5M; }
    if (month == "Dec") { Incrementval = current + 0.5M; }


    Name : Dotnet Developer-2015
    Email Id : kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.


  • Sign In to post your comments