Click here to Skip to main content
15,936,565 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hie guys i have a problem i've a button and a listbox let me give u the code button clicl event & xplain
VB
Dim startDate As Date
Dim addedDate As Date
startDate=#27/10/2011#
Dim k As Integer
For  k =0 to 5
   addedDate= startDate.AddMonth(1)
   ListBox1.Items.Add(addedDate)
Next 
Here is the problem the program adds 5 dates to the listbox, which are the same i.e
27/11/2011, 27/11/2011, 27/11/2011, 27/11/2011, 27/11/2011
instead of showing different dates with one added month as shown below in the expect outcome
27/11/2011, 27/12/2011, 27/01/2012, 27/02/2011, 27/03/2011
i've googled this problem for the last 3 days
Posted
Updated 13-Aug-11 21:56pm
v2
Comments
Sergey Alexandrovich Kryukov 15-Aug-11 2:05am    
Please try to use English. What's "clicl", "xplain"?
--SA

1 solution

Try:
VB
addedDate = startDate
For  k =0 to 5
   addedDate= addedDate.AddMonth(1)
   ListBox1.Items.Add(addedDate)
Next
 
Share this answer
 
Comments
sijimann 14-Aug-11 4:56am    
Thanx man it worked u r such a star :-)
OriginalGriff 14-Aug-11 5:01am    
No problem!

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