string转换成date类型 vb.net
时间: 2023-04-08 13:05:06 浏览: 151
String与date的转换
可以使用DateTime.Parse或者DateTime.TryParse方法将string类型转换成date类型,例如:
Dim strDate As String = "2021-07-01"
Dim dtDate As DateTime = DateTime.Parse(strDate)
或者
Dim strDate As String = "2021-07-01"
Dim dtDate As DateTime
If DateTime.TryParse(strDate, dtDate) Then
'转换成功
Else
'转换失败
End If
阅读全文