如何在VB 6中的A压延机控件中比较两周的周数,请帮帮我 [英] How to compare Week of two days in A calender Control in VB 6 please help me out
问题描述
我要从日历中添加一天到列表视图,如果我从日历中单击另一天,则该日期不应该来自列表视图中的同一周
我该怎么办
请帮助我Out
I m adding a day from Calender into List view , if i Click another Day from Calendar Its Should not be From the Same Week Which were there in the List view
How can i do it
plz help me Out
推荐答案
假设
变量d1具有日期(现有)
变量d2输入了新日期
这是要检查的一段代码
Assuming
variable d1 has the date (existing)
variable d2 has the new date entered
here''s a piece of code to check
Dim i As Integer
i = DateDiff("d", DateAdd("d", -(Weekday(d1)), d1), d2)
If i < 0 Or i > 6 Then
MsgBox "Error"
End If
一行太多?
这个想法是要获取d1&的第一个工作日的日期.然后检查d2是否在d1的7天内(0-6)
我在这里砍了
Too much in one line?
The idea is to get the date of the first weekday of d1 & then to check if d2 is within 7 days (0-6) of d1
I''ve chopped it down here
Weekday(d1)
(第1步)获取工作日(0 =星期日至7 =星期六)
(step 1)gets the weekday (0=sun to 7=sat)
DateAdd("d", -(step1), d1)
(步骤2)获取星期几的开始日期
(step 2) gets the date of the week''s beginning
DateDiff("d", step2, d2)
(第3步)获得差值(d2与一周开始的距离)
然后检查是否在7天内
(step 3) gets the difference (how far is d2 from the week''s beginning)
Then you check if it''s within 7 days
这篇关于如何在VB 6中的A压延机控件中比较两周的周数,请帮帮我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!