简体   繁体   中英

Date validation in visual basic

当我以10/28/2012格式传递日期时,我试图获得一个真假布尔值,我尝试过IsDate(“10/28/2012”)但是当我这样做时它总是返回false,这应该实际上返回true,是否有人给我一个关于我做错了什么的想法,是否有什么我应该在它被传递到isDate之前做的字符串?

You should use Date.TryParse(s as string, result as Date) As Boolean

Where s is the string you're testing, and result is the Date you would like to store the parsed date in. If you do not care about the Date, and would only like to figure out if the value is a date, then you can just give it new Date . The function will return True if the parse succeeded, or False if it failed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM