1.文法
Type を利用します2.サンプル
'#--------------
' ユーザ型の宣言
'#--------------
Type UserType
Id As Integer
Name As String
End Type
Sub Macro1()
Dim User As UserType
User.Id = 1
User.Name = "いけいけ理系NEO"
Debug.Print (User.Id)
Debug.Print (User.Name)
End Sub
3.実行結果
1
いけいけ理系NEO
が表示されます
PR
Date関数を利用します1.サンプル
Debug.Print Date
2.実行結果
イミディエイトウインドウに
本日日付が表示されます
1.サンプル
Dim myDict As Object
Dim i As Variant
Set myDict = CreateObject("Scripting.Dictionary")
'' セット
myDict.Add "A", 10
myDict.Add "B", 20
myDict.Add "C", 30
''表示
For Each i In myDict
Debug.Print i
Debug.Print myDict(i)
Next i2.実行結果
myDict の内容が表示されます
1. 考え方
Timer を使います。
2.サンプル
Sub MySub()
Dim l As Long
Start = Timer
For l = 1 To 10000000
l = l + 1
Next l
Debug.Print Timer - Start
End Sub
3.実行結果
For ループの時間が、秒で表示されます。
1. 文法
Debug.Assert ブール式
で、ブール式がFalseの場合だけ、
処理が中断され、そこで、止まります。2.サンプル
Sub MySub()
Dim l As Long
For l = 0 To 10
Debug.Print l
Debug.Assert l = 0
Next l
End Sub3.実行結果
イミーディエイトウインドウに、
0
1
と表示された後に、処理が止まります。