参考代码
dim str as string = “2017-01-01”Dim d As DateIf Date.TryParse(str, d) Then If d < Date.today Then msgbox("日期小于今天") End If Dim sp As TimeSpan = Date.Today - d msgbox("相差" & sp.TotalDays)Else msgbox("日期无效")End If