I have a string variable
Dim SHG As String
SHG = "FILENAME" + "_" + "Jan12"
Here the File name is constant and the Jan12 is not a fixed one.
Here i want to increament this to 13,14,15.. and etc and same as month also like jan,feb,march,april,may,june,july,aug .... dec
how can i increament thie and store in a variable.
Jan12,Feb12...,Jan13,Feb13...
Post Solution for this post
Thanks in advance
Loading

VulpesRank #55 · 29.2K reputationPosted Feb 29, 2012, 12:35 AM EST
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 29, 2012, 12:37 AM EST
I have Few que on Requirement.
1) up to what number you want to increament ?
2) what is business logic?
Rajkumar R175 reputationPosted Feb 29, 2012, 12:45 AM EST
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 29, 2012, 1:09 AM EST
Try this...
string year = DateTime.Now.Year.ToString().Substring(2, 2);
DateTime date = new DateTime(1900, 1, 1);
for (var r = 1; r <= 12; r++)
{
Console.WriteLine("FILENAME_" + date.ToString("MMM") + year);
date = date.AddMonths(1);
}
this code is work for only current year. i.e. 2012
but que is year is start from where?
hope this help.
Rajkumar R175 reputationPosted Feb 29, 2012, 2:10 AM EST
Jignesh TrivediRank #16 · 50.3K reputationPosted Feb 29, 2012, 2:23 AM EST
so try this..
int startYear = 2005;
int currentYear = DateTime.Now.Year;
for (var y = startYear; y <= currentYear; y++)
{
DateTime date = new DateTime(y, 1, 1);
string year = y.ToString().Substring(2, 2);
for (var r = 1; r <= 12; r++)
{
Console.WriteLine("FILENAME_" + date.ToString("MMM") + year);
date = date.AddMonths(1);
}
}
hope this ans of que.