「VB.NET」CDateを使用して文字列をData値に変換
書式
CDate(文字列)
使用例
Module Module1 Sub Main() Dim aDateStr, aTimeStr As String Dim aDate, aTime As Date aDateStr = "February 11, 2021" aTimeStr = "09:35:47 AM" '文字列aDateStrをDate値に変換 aDate = CDate(aDateStr) Console.WriteLine(aDate) ' 文字列aTimeStrをDate値に変換 aTime = CDate(aTimeStr) Console.WriteLine(aTime) Console.ReadKey() End Sub End Module
結果
2021/02/11 0:00:00
0001/01/01 9:35:47