(for Internet Explorer)
Function  IsDate( Value as Date or string ) as boolean
Value に指定した値が、Date 型か、日付として有効な文字列かどうかを返します。
Function  IsNumeric( Value as integer or string ) as boolean
Value に指定した値が、整数型か、浮動小数型か、数字からなる文字列かどうかを返します。
サンプル
IsNumeric( 1 ) = True
IsNumeric( 1.2 ) = True
IsNumeric( "1" ) = True
IsNumeric( "1,000" ) = True
関連
関連
は、ありません。
CLng
CSng
CDbl
CStr
FormatCurrency
FormatDateTime
FormatPercent
列挙型, Enum (VBScript)
VBScript には、列挙型がないので、下記のようにするとよいでしょう。
'-------------------------------------------------------------------------
' ### <<<< [SampleEnum] >>>>
'-------------------------------------------------------------------------
Class  SampleEnumClass
    Public  Foo
    Public  Bar

    Private Sub  Class_Initialize()
        Foo = 1
        Bar = 2
    End Sub

    Public Function  Str( EnumValue )
        Select Case  EnumValue
            Case  Foo : Str = "Foo"
            Case  Bar : Str = "Bar"
        End Select
    End Function
End Class

Dim  SampleEnum : Set SampleEnum = new SampleEnumClass
使用するとき
型の定義
variable = SampleEnum.Foo
WScript.Echo  SampleEnum.Str( variable )
Set ns = SampleEnum  '// Copy name space
variable = ns.Foo
WScript.Echo  ns.Str( variable )
SampleEnum 名前空間にある Foo というシンボル
True
= -1 (全ビット1)
False
Not
全ビット反転
= 0
And
Or
全ビット論理積
全ビット論理和
引数に Boolean を指定すると、機能追加により引数が増えてしまうことが多いので、
Flags 型
を使うことをお勧めします。
ビットが1かどうか
ビットが0かどうか
Flags and 4
(Flags and 4)=0
not(Flags and 4) ではありません
Option Explicit

Class Book
  Public  Title  ' メンバ変数
  Public  Price  ' メンバ変数
End Class

main

Sub main
  Dim  book,dic,key,keys
  Set book = New Book
  book.Title = "Book Title"
  book.Price = 400

  Set dic = CreateObject( "Scripting.Dictionary" )

  dic.Add "key1", book
  MsgBox dic.Item("key1").Title
  If dic.Exists("key1") Then  MsgBox "!"

  For Each key in dic.Keys  '// or dic.Items
    WScript.Echo key & " " & dic.Item(key).Price
  Next

  dic.Remove "key1"
  dic.RemoveAll
End Sub
文字列(Key)から、数値やオブジェクトなど(Item)を高速に引き出します。
Scripting.Dictionary
Remove
RemoveAll
Dictionary
Key は重複できません。
Key は、文字列、または、整数値、または ""
要素をデバッガでウォッチするときは、Keys, Items プロパティを参照します。
Key
Key
Item
Item
Key
Item
    Set dic = CreateObject( "Scripting.Dictionary" )
生成
サンプル
関連
    Const  c_NotCaseSensitive = 1
    Set dic = CreateObject( "Scripting.Dictionary" )
    dic.CompareMode = c_NotCaseSensitive
生成
Key の大文字小文字を区別しない
関連
Sub  Dictionary::Add( Key as string, Item as variant )
要素を追加します。
すでに Key がある時は、エラー 0x1C9 になります。
すでに Key があるかどうかに関わらず設定するときは、
を使って
ください。
Count (Dictionary)
Property Get  Dictionary::Count() as integer
要素の数
Function  Dictionary::Keys() as array of string
Dictionary の中にある要素のうち、キーを集めた配列を返す
Dictionary
Key  Item
Key  Item
Key  Item
  For Each key in dic.Keys
    WScript.Echo key & " " & dic.Item(key)
  Next
次のようにすれば、Key と Item の両方を参照できます。
Function  Dictionary::Items() as array of variant
Dictionary の中にある要素のうち、アイテムを集めたコレクションを返す
Dictionary
Key  Item
Key  Item
Key  Item
Default Property Get  Dictionary::Item( Key as string ) as variant
引数 key をキーとした item を返します。
dic.Item("key1") = 1
Set  dic.Item("key2") = New Class
ただし、次のようにしても、item は変更できません
item = dic.Item("key1")
item = 1
item <> dic.Item("key1")
登録されていないときは、新規に登録します。
返した item は参照返しなので、下記のように設定することができます。
dic("key1") = 1  '// dic.Item("key1") = 1
関連
Item はデフォルト・プロパティです。 .Item を省略できます。
登録したくないときは Exists で調べるか、
を使用してください。
キーが登録済みのときにエラーにするときは、
を使ってください。
Function  Dictionary::Exists( Key as string ) as boolean
指定したキーに対応する要素が入っているかどうかを返します。
関連
キーが存在しないときに自動的にキーを追加しない辞書
Property  Dictionary::CompareMode  as integer
キーの種類。 同じキーとして扱う条件。
0
バイナリ比較、大文字小文字を区別
1
文字列比較、大文字小文字を区別しない
他にもあります
  Const  NotCaseSensitive = 1
  Dim  dic : Set dic = CreateObject( "Scripting.Dictionary" )
  dic.CompareMode = NotCaseSensitive
サンプル:
注意
すでにデータが入っているときは、エラーになります。
Sub  Dictionary::Remove( Key as string )
登録されていないキーが指定されたら、エラーになります。
Sub  Dictionary::RemoveAll()
Set re = CreateObject( "VBScript.RegExp" )

re.Pattern = "^aaa.*bbb.c"
WScript.echo  re.Test( "aaaxxxbbbyc" )
→ 正規表現
-1
出力
(True)
関連
メソッド
テストされる
文字列
axbmacb
a.b
True
axb, acb
axbmacb
x
False
x
True
True
axbmacb
a.b
False
入力データ
出力データ
axb
True
False
-
False
^x
axbmacb
aaa
bbb
a
b
-
True
a
b
aaa
ccc
a
b
-
-
False
-
a.*b
aaa
bbb
-
False
Function  RegExp::Execute( s as string ) as Matches
正規表現にマッチするかどうかテストし、マッチしたものを返します。
【引数】
s
テストされる文字列
返り値
マッチしたもの
【補足】
に検索条件を設定してから呼び出してください。
    Set re = CreateObject( "VBScript.RegExp" )

    re.Pattern = "a.b"
    re.Global = True
    Set matches = re.Execute( "raxbmacb" )

    WScript.echo  "Match count = " & matches.Count
    For Each  match  In  matches
        WScript.echo  "FirstIndex = " & match.FirstIndex & _
            ", Length = " & match.Length & ", Value = " & match.Value
    Next
出力
Match count = 2
FirstIndex = 1, Length = 3, Value = axb
FirstIndex = 5, Length = 3, Value = acb
正規表現 = "a.b", テストされる文字列 = "raxbmacb", 複数検索する
サンプル
RegExp::Global = False のときは、Matches::Count は 0 か 1 のどちらかになります。
参考
FirstIndex は、0 = 1文字目です。
Integer  .FirstIndex
マッチした位置、最初=0、2バイト文字も 1 でカウント
Integer  .Length
マッチした文字列の文字数、2バイト文字も 1 でカウント
String  .Value
マッチした文字列
サンプル
でテストした結果です。
サンプル
    Set re = CreateObject("VBScript.RegExp")

    re.Pattern = "<DIV .*>"
    re.Global = True
    Set matches = re.Execute( text )

    For Each  match  In  matches
        attr = sscanf( match.Value, "id=""%s""" )
        text = Left( text, match.FirstIndex ) +_
            "<DIV id="""+ attr +""" plus=""add"">" +_
            Mid( text, match.FirstIndex + match.Length + 1 )
    Next
match
任意の id属性(ワイルドカード)を持つ DIVタグに、plus 属性を加える
Matches オブジェクトのプロパティ
Match  ( Index )
Integer  .Count
マッチした数
Index + 1 番目のマッチした内容。 Index >= 0
String  .SubMatches(n)
( ) で区切られた Pattern のそれぞれのマッチした
文字列。 n>=0。 要素数は、.SubMatches.Count。
参考
TypeName は、"IMatch2" です。
Function  RegExp::Test( s as string ) as Boolean
正規表現にマッチするかどうかテストし、1つでもマッチしたかどうかを返します。
【引数】
s
テストされる文字列
返り値
マッチした文字列があるかどうか
Set re = CreateObject("VBScript.RegExp")

re.Pattern = "^aaa.*bbb.c"
WScript.echo  re.Test("aaaxxxbbbyc")
-1
出力
(True)
に検索条件を設定してから呼び出してください。
(もし 0 なら False)
引数 s の一部にヒットしたときでも、True を返します。
Me.Pattern の先頭に "^"、末尾に "$" を付けると、引数 s の一部にヒットした
ときは、False を返します。
サンプル
Function  RegExp::Replace( s as string, to as string ) as string
正規表現を使って、文字列の一部を置換します。
【引数】
s
to
入力文字列(置き換える前の文字列を含む文字列)
置き換えた後の文字列
返り値
Set re = CreateObject( "VBScript.RegExp" )

re.Pattern = "a.b"
re.Global = True
WScript.echo  re.Replace( "raxbmacb", "---" )
r---m---
出力
出力文字列(置き換えた後の文字列を含む文字列)
に設定してから呼び
サンプル
サンプル
Set re = CreateObject( "VBScript.RegExp" )
re.Pattern = "%([0-9]+)"
WScript.echo  re.Replace( "%123", "$1" )
re.Global = True
WScript.echo  re.Replace( "%123 %456", "<$1>" )
出力
123
<123> <456>
注意: $1 は、他の正規表現
ライブラリで指定する ${1}
と同じ意味ですが、${1} と
指定できません。
→ 正規表現を使った置換
参考
置き換える前の文字列(検索条件)を
出してください。
Dim  RegExp::MultiLine as boolean
Pattern に、行頭 "^"、行末 "$" が使えるようにします。
  Set re = CreateObject("VBScript.RegExp")

  re.Pattern = "A.*"+vbCR+"?"+vbLF+"^D"
  re.MultiLine = True
  Set matches = re.Execute( "ABC"+ vbCRLF +"DEF"+ vbCRLF )

  echo  "Match count = " & matches.Count
  For Each match  In matches
    echo "FirstIndex = " & match.FirstIndex & _
                 ", Length = " & match.Length & ", Value = " & match.Value
  Next
サンプル
"ABC"+ vbCRLF +"DEF"+ vbCRLF に対して、"A.*"+vbCR+"?"+vbLF+"^D" がマッチするには、
MultiLine を True にする必要があります。 "^" がない "A.*"+vbCR+"?"+vbLF+"D" にマッチ
するには、MultiLine は False でも構いません。

改行文字は、任意の文字 "." や、行頭 "^" や、行末"$" にマッチしないので、 vbCR+"?"+vbLF
を指定する必要があります。 これは、MultiLine の値がどちらでも、違いはありません。
Match count = 1
FirstIndex = 0, Length = 6, Value = ABC
D
出力
書きかけ
${ } 変数 から ${ } 関数へ
${Func(ABC)}
c = ( a  mod  b )
剰余。 あまり。 9 Mod 4 = 1, -9 Mod 4 = -1
16進数の 1F (10進数の値は 31)
&h8000 〜 &hFFFF と、&h80000000 〜 &hFFFFFFFF は、マイナス
-32767〜+32767 は、Integer です。 -32768 は Long です。
Const  Err_TestSkip = 2
定数。 参照する場所より上に記述する必要がある
Execute されるコードには再度記述が必要
→ クラスの定数
c = a and b
c = a or b
論理積
論理和、1 にするビット演算
c = a \ b
商(割った結果を整数にする)。 四捨五入あり
If は、0以外で真になります
hex_str = Hex( 16 )
CInt(1.9) = 2, Int(1.9) = 1, Fix(1.9) = 1
CInt(1.9) = -2, Int(-1.9) = -2, Fix(-1.9) = -1
c = a xor b
c = a and not b
排他的論理和
0 にするビット演算
キーワード:
関連
参考
参考
16進数 &h8000 〜 &hFFFF の正の値を取得するとき。
… VBScript では下記 CLng
関連
\
引数は、文字列であること。 " " で囲まないと NG
c = a * n^2
c = a \ n^2
n ビット左シフト
n ビット右シフト。 \ は商(上記)。 四捨五入に注意。