変数が日付型かどうかをチェックする( IsDate 関数 )
IsDate 関数の使い方
【書式】
result = IsDate( expression )
【引数・戻り値】
- expression ・・・ 調べる変数や式
- result ・・・ 引数 expression が、日付型( Date 型 )に変換できる(日付として解釈)できるかどうかを調べた結果(ブール型:日付型に変換可能な場合は、True / それ以外の場合は、False )。
IsDate 関数の使用例
サンプルVBAソース
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
Sub Sample_isdate() '以下、True を返す Debug.Print IsDate(#4/1/2015#) Debug.Print IsDate(#6/21/2013 7:02:23 PM#) Debug.Print IsDate(DateSerial(2012, 1, 1)) Debug.Print IsDate(Now) Debug.Print IsDate("2000,4,11") Debug.Print IsDate("1:20") Debug.Print IsDate("2005/9/1 11:30 AM") Debug.Print IsDate("昭和60年7月20日 1時30分") '以下、False を返す Debug.Print IsDate("おはよう!") Debug.Print IsDate(42005) Debug.Print IsDate(0) Debug.Print IsDate("") Debug.Print IsDate(Empty) Debug.Print IsDate(Null) End Sub |
実行結果
関連記事
-
-
連想配列(Dictionary オブジェクト)
連想配列 連想配列とは、添字(キー)に文字列を使用することができる配列です。 V …
-
-
色の設定(Color プロパティ・RGB 関数)
Color プロパティ Color プロパティは、指定したオブジェクトの色を取得 …
-
-
テキストファイル(UTF-8)を読み込み、書き出し(ADODB.Stream)
Stream オブジェクト ADO(ActiveX Database Objec …
-
-
インプットボックスを表示する(InputBox関数・InputBoxメソッド)
「InputBox関数」と「InputBoxメソッド」の違い 「InputBox …
-
-
コレクション(Collection)オブジェクト「連想配列」
コレクション(Collection)オブジェクトの使い方 【書式】 Dim my …
-
-
文字列:指定した数の空白(スペース)からなる文字列を返す(Space 関数)
Space 関数 【書式】 result = Space ( number ) …
-
-
式の値に応じて多分岐を行う(Switch 関数)
Switch 関数 の使い方 Switch 関数は、「式・値」を対にして指定して …
-
-
カレントフォルダの取得・設定(DefaultFilePath プロパティ)
DefaultFilePath プロパティ カレントフォルダとは、ブックを開いた …
-
-
日付時刻:現在の日付・時刻を取得・設定(Now、Date、Time)
現在の日付・時刻を取得・設定 現在の日付・時刻を取得(Now 関数、Date 関 …
-
-
色の設定(ColorIndex プロパティ・Colors プロパティ)
ColorIndex プロパティ ColorIndex プロパティは、指定したオ …
