如果经过特定天数,则触发操作VB.NET [英] Trigger Action if a specific amount of days is gone VB.NET

查看:95
本文介绍了如果经过特定天数,则触发操作VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码已经可以使用了,但是仅适用于Filesystem.FileDateTime,为此我需要一个文件,但是当我用日期字符串替换它时,即使我发现filedatetime的datemethod与其相同,也无法使用我写Now.ToString时将返回.

WORKS;

This code below works already, but only with Filesystem.FileDateTime, and for this i need a file, but it doesnt work when i replace it with a date string even i found out that the datemethod of filedatetime the same is as it will be returned when i write Now.ToString.

WORKS;

If DateDiff("d", FileSystem.FileDateTime("C:\example.ini"), Now) > 15 Then
MsgBox("The Free Version reached the Free Limit of 15 Days") : Else : End If



不工作;



DOESNT WORK;

If DateDiff("d", 1.5.2012 12.00.00MD, Now) > 15 Then
MsgBox(""): Else : End If



我是否必须将其声明为日期或字符串,还是想念其他东西?
这是非常困难的,因为要证明正确的解决方案,我必须至少等待一天.提前谢谢!

已添加代码标签-LOSMAC [/EDIT]



Do i have to declare it as date or as string or did i miss something else?
This is very difficult since to prove the right solution i must wait at least one day. Thanks in advance!

Code tags added - LOSMAC[/EDIT]

推荐答案

是的,您必须先创建日期,然后执行DateDiff.
像这样的东西.

Yes, you have to create date and then do DateDiff.
Some thing like this.

If DateDiff("d", new System.DateTime(2012,5,1,12,0,0), Now) > 15 Then
MsgBox(""): Else : End If


DateDiff需要2个日期是DateTime. 1.5.2012 12.00.00MD不是DateTime,因此将其转换为1并使用它.
DateDiff requires the 2 dates to be DateTime. 1.5.2012 12.00.00MD is not a DateTime, so convert it to one and use it.


这篇关于如果经过特定天数,则触发操作VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆