変数が日付型かどうかをチェックする( 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 |
実行結果
関連記事
-
-
オートシェイプの種類を表す定数(MsoAutoShapeType 列挙型)
MsoAutoShapeType 列挙型 オートシェイプオブジェクトの図形の種類 …
-
-
文字列:文字列変数の値を右詰めまたは左詰めにする(RSet ステートメント・LSet ステートメント)
RSet ステートメント・LSet ステートメント 【書式】 < RSet ステ …
-
-
Join 関数(配列の要素を結合)
Join 関数 1次元配列の各要素を指定した区切り文字で連結します。 【書式】 …
-
-
カレントフォルダの取得・設定(DefaultFilePath プロパティ)
DefaultFilePath プロパティ カレントフォルダとは、ブックを開いた …
-
-
日付時刻:現在の日付・時刻を取得・設定(Now、Date、Time)
現在の日付・時刻を取得・設定 現在の日付・時刻を取得(Now 関数、Date 関 …
-
-
Split 関数(文字列型の一次配列を作成)
Split 関数の使い方 【書式】 myArray = Split ( expr …
-
-
色の設定(ColorIndex プロパティ・Colors プロパティ)
ColorIndex プロパティ ColorIndex プロパティは、指定したオ …
-
-
配列の添字の最小値を「1」に設定する
Option Base ステートメントを使用する 【書式】 Option Bas …
-
-
文字列:文字を指定数並べた文字列を返す(String 関数)
String 関数 【書式】 result = String ( number, …
-
-
データ型を調べて、そのデータ型を示す数値を返す(VarType 関数)
VarType 関数 の使い方 VarType 関数は、引数に、データ型を調べた …
