双周日期 2011 VB6
我试图在 VB6 中使用此代码循环获取所有 2011 年双周日期:
Dim HardDate As Date
Dim NumberOfDaysSince As Integer
Dim modulus As Integer
Dim DaysToNext As Integer
Dim nextpayday As Date
Dim x As Integer
x = 1
DateToday = Date
HardDate = Format(Now, "m/dd/yyyy")
Do While x <> 20
NumberOfDaysSince = DateDiff("d", HardDate, DateToday)
modulus = NumberOfDaysSince Mod 14
DaysToNext = 15 - modulus
nextpayday = Date + DaysToNext
Debug.Print nextpayday
HardDate = DateAdd("d", 1, nextpayday)
DateToday = DateAdd("d", 10, HardDate)
x = x + 1
Loop
但是,使用上面的代码不会产生持续的双周日期...
任何帮助都会很棒!
日期示例
Pay Begin Date | Pay End Date | Check Date | Posts
-------------------------------------------------------------------
1/14/2011 | 1/24/2011 | 2/10/2011 | 2/3/2011
1/28/2011 | 2/10/2011 | 2/24/2011 | 2/17/2011
2/11/2011 | 2/24/2011 | 3/10/2011 | 3/3/2011
大卫
I am trying to loop to get all 2011 bi-weekly dates using this code in VB6:
Dim HardDate As Date
Dim NumberOfDaysSince As Integer
Dim modulus As Integer
Dim DaysToNext As Integer
Dim nextpayday As Date
Dim x As Integer
x = 1
DateToday = Date
HardDate = Format(Now, "m/dd/yyyy")
Do While x <> 20
NumberOfDaysSince = DateDiff("d", HardDate, DateToday)
modulus = NumberOfDaysSince Mod 14
DaysToNext = 15 - modulus
nextpayday = Date + DaysToNext
Debug.Print nextpayday
HardDate = DateAdd("d", 1, nextpayday)
DateToday = DateAdd("d", 10, HardDate)
x = x + 1
Loop
However, using that code above does not produce an on going bi-weekly date...
Any help would be great!
date example
Pay Begin Date | Pay End Date | Check Date | Posts
-------------------------------------------------------------------
1/14/2011 | 1/24/2011 | 2/10/2011 | 2/3/2011
1/28/2011 | 2/10/2011 | 2/24/2011 | 2/17/2011
2/11/2011 | 2/24/2011 | 3/10/2011 | 3/3/2011
David
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您知道 2011 年想要的第一次约会,并且知道想要 26 个两周,那么代码可以极其简化。出于说明目的,将文本框“Text1”添加到表单,并在设计器中设置 MultiLine = True。我们将使用 1/7/2011 作为开始日期:
文本框中显示的输出如下所示:
Assuming you know the first date you want in 2011, and you know you want 26 fortnights, the code can be simplified extremely. For illustration purposes, add a textbox "Text1" to a form, and set MultiLine = True in the designer. We'll use 1/7/2011 for our starting date:
The output that shows in the textbox looks like this: