変数が日付型かどうかをチェックする( 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 |
実行結果
関連記事
-
-
日付時刻:数値から日付・時刻データを取得( DateSerial 関数、TimeSerial 関数 )
DateSerial 関数(数値を使って日付データを取得) 【書式】 date …
-
-
指定した数のスペースを挿入する(Spc 関数)
指定した数のスペースを挿入 指定した数のスペースを挿入するには、Spc 関数を使 …
-
-
日付時刻:日付時刻から情報取得( DatePart 関数 )
DatePart 関数(日付・時刻の値から情報を取得) 【書式】 result …
-
-
文字列:文字を指定数並べた文字列を返す(String 関数)
String 関数 【書式】 result = String ( number, …
-
-
日付時刻:経過時間を取得( Timer 関数 )
Timer 関数の使い方 【書式】 result = Timer () 【戻り値 …
-
-
文字列:文字列を最後から検索してその最初の文字位置を返す(InStrRev 関数)
InStrRev 関数 任意の文字列の中で、指定した文字列を最後から検索して、見 …
-
-
文字列:文字列右から指定文字数取得(Right 関数,RightB 関数)
Right 関数・RightB 関数 の使い方 【書式】 result_righ …
-
-
ユーザー定義関数:セルを取得する(ThisCell プロパティ)
入力されたセルを取得する ワークシート上で使用する Function プロシージ …
-
-
色を設定する(QBColor 関数)
QBColor 関数 QBColor 関数は、指定した色番号に対応するRGB コ …
-
-
文字列:指定した文字の文字コードを取得する(Asc 関数)
Asc 関数 【書式】 result = Asc ( string ) 引数・戻 …
