次のように、短縮表記で整数変数 testInt を宣言しました。
Dim testInt%
使用に違いはありますか
somevalue = testInt * testInt
対
somevalue = testInt% * testInt%
要するに、変数が参照されるすべてのポイントで型指定子を使用する利点はありますか?
クイックタイムテストは、彼らがラインボールであることを示しています - これは直感的に理にかなっています
Long
よりもむしろを使用Integer
すると、より効率的になります。このMSFTリンクを参照してください
より正確な API タイマーでこれを繰り返します
Sub B()
Dim testInt%
Dim somevalue%
Dim lcnt As Long
Dim dbStart As Double
dbStart = Timer()
For lcnt = 1 To 100000000
somevalue = testInt * testInt
Next
MsgBox "Time was " & Timer() - dbStart
End Sub
Sub A()
Dim testInt%
Dim somevalue%
Dim lcnt As Long
Dim dbStart As Double
dbStart = Timer()
For lcnt = 1 To 100000000
somevalue = testInt% * testInt%
Next
MsgBox "Time for type-specified was " & Timer() - dbStart
End Sub