VB 固定日期,格式为yyyy-mm-dd,加上固定天数的方法,谢谢.

来源:百度知道 编辑:UC知道 时间:2024/09/25 00:36:39
我那个固定日期是在一个txt文件里的,可用OPEN拿出来,名称为DDateFirst,格式为yyyy-mm-dd

DateAdd("d", N,format(DDateFirst,"yyyy-mm-dd") )
在原来的基础上加N天

dim pDqty '声明一个变量,作为固定的天数
pDQty=10
msgbox format(#2009-8-3# + pDQty ,"yyyy-mm-dd")

结果,弹出:2009-08-13

例如:
Dim Ddatefirst, DDateEnd
Ddatefirst = #2008-09-05#
DDateEnd = Ddatefirst + 89

If Date > DDateEnd Then
MsgBox "软件到期,请注册!"
End If

假设你要定义的那个固定天数为const ,原来的日期为"yyyy-mm-d0d0"
dim shijianyuanlai as string
dim nian as integer,yue as integer ,tain as integer
shijianyuanglai= "yyyy-mm-d0d0"
nian=val(left(shijianyuanglai,4))
yue=val(mid(shijianyuanglai,6,2))
tian=val(right(shijianyuanlai,2))
tian=tian+const
If tian> 31 Then
If yue = 1 Or 3 Or 5 Or 7 Or 8 Or 10 Or 12 Then tian = tian - 31: yue = yue + 1
If yue> 12 Then yue = rqmm - 12: nian = nian + 1
End If
If tian > 30 Then