Click here to Skip to main content
15,912,069 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to generate numbers that look like 20100000000001 and
increasing each time by one that looks like 20100000000002 and so continue
every time up by one at each execution, and only change in the year gain, where it think 2010 is the year and changes each year new and
start all over again 20110000000001

thank you for your cooperation
Posted
Updated 21-Jun-10 5:54am
v4
Comments
#realJSOP 21-Jun-10 12:50pm    
This is extremely basic stuff. Specifically, you should be able to nut through this with relative ease. THINK ABOUT THE PROBLEM.

Very Easy to do, and I will give a full answer once the TIMELOCK is off the edit so that I can make the question readable.
 
Share this answer
 
Comments
sweet_memory 21-Jun-10 12:03pm    
thank you for your cooperation but how to do that because i'm new member
public class MyPointlessClass
{
    DateTime lastTime = new DateTime(0);
    Int64 myNumber = 0;

    // as a string
    private string UpdateRunCount()
    {
        DateTime now = DateTime.Now;
        if (now.Year != lastTime.Year)
        {
            myNumber = 1;
        }
        string number = string.Format("{0}{1:0000000000}", now.ToString("yyyy"), myNumber);
        lastTime = 
        return number;
    }

    // as a numeric value
    private Int64 UpdateRunCount()
    {
        DateTime now = DateTime.Now;
        if (now.Year != lastTime.Year)
        {
            myNumber = 1;
        }
        Int64 number = (now.Year * 10000000000) + myNumber;
        return number;
    }

}
 
Share this answer
 
Comments
sweet_memory 22-Jun-10 11:31am    
thank you for your cooperation but please how to make the number start to count from 1 when the year change like these
201000000000001,20100000000002,20110000000001,2011000000000002
#realJSOP 22-Jun-10 18:05pm    
It's in the code I gave you.

You're gonna have to make the code I gave you fit your situation.
sweet_memory 25-Jun-10 16:42pm    
thank you for your cooperation

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900