Visual Basic サンプル集 |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Visual Basic 中学校 > Visual Basic サンプル集 > Visual Basic サンプル集目次 >
日付が存在するか調べる
2020/6/17
"2022/2/29" が存在するか調べる
If IsDate("2022/2/29")
Then Debug.WriteLine("存在する日付です。") Else Debug.WriteLine("存在しない日付です。") '←こちらが表示されます。 End If |
"2021/7/31"が存在するなら日付型の値を取得する
Dim result
As Date If Date.TryParse("2021/7/31", result) Then Debug.WriteLine(result.ToString("yyyy\/MM\/dd") & " を取得しました。") '←こちらが表示されます。 Else Debug.WriteLine("存在しない日付です。") End If |