VB.NET中的循环日期值 [英] Looping date values in VB.NET
本文介绍了VB.NET中的循环日期值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
伙计们,我有一个问题,我有一个按钮,一个列表框让我给你代码按钮clicl事件& xplain
Hie guys i have a problem i''ve a button and a listbox let me give u the code button clicl event & xplain
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
这是程序在列表框中添加5个日期的问题,这些日期是相同的,即
27/11/2011、27/11/2011、27/11/2011、27/11/2011、27/11/2011
而不是在预期结果中显示如下所示的增加一个月的不同日期
27/11/2011、27/12/2011、27/01/2012、27/02/2011、27/03/2011
我在过去3天内用Google搜索了此问题
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
推荐答案
尝试:
addedDate = startDate
For k =0 to 5
addedDate= addedDate.AddMonth(1)
ListBox1.Items.Add(addedDate)
Next
这篇关于VB.NET中的循环日期值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文