文字列を、
Date Serial に変換できるかどうか、テストします。
構文:
用法:
#include "vbcompat.bi"
result = IsDate
( stringdate )
パラメタ:
戻り値:
日付文字列を
Date Serial に変換できるなら、非ゼロ (-1) を返します。そうでなければ、ゼロ (0) を返します。
記述:
日付文字列は、OS の地域の設定で、有効な日付(mm-dd-yyyy) の形式で設定しなければなりません。
地域の設定が、QB が使用したのと同じ日付の形式を指定する場合にだけ、
IsDate(Date) は非ゼロ(-1) を返します。
vbcompat.bi か datetime.bi が含まれていないと、コンパイラは、この関数を認識しません。
例:
#include "vbcompat.bi"
Dim s As String, d As Long
Do
Print
Print "日付を入力してください:
"
Line Input s
If s = "" Then Exit Do
If IsDate( s ) = 0 Then
Print "'";s;
"' 有効な日付ではありません"
Else
d = DateValue
( s )
Print "year = ";
Year( d )
Print "month = ";
Month( d )
Print "day = ";
Day( d )
End If
Loop
QBからの違い:
参照: