これはまぁ意外性はないんですけど、とりあえず測定だけはしておこうかと。
.Netだったら。VBではAndAlso、C#では&&とかが使えるんですけど、VBAでは使えませんものね。
というわけで、またの名を、And v.s AndAlso ってコトですかね?!これをVBAではAnd とIfのネスト構造で再現して対決します。
(1)If IsCheck(i) And IsCheck(i + 1) Then
(2)If IsCheck(i) Then if IsCheck(i + 1) Then
結果
(1):3436 ミリ秒 (2):2563 ミリ秒
※Access2003で実験
サンプルソース
フォームにtxtDATAという名前のテキストボックスを作って、そこにタイムを表示する。clsTimerMMクラスは「時間経過計測クラス‐VBA編」参照。
Dim ClsTimerMM As ClsTimerMM
Dim strTextMsg As String
'************************
Dim lngMax As Long
Dim i As Long
'************************
Set ClsTimerMM = New ClsTimerMM
lngMax = 10000000
'************************
ClsTimerMM.SetStartDate
For i = 0 To lngMax
If IsCheck(i) And IsCheck(i + 1) Then
End If
Next
strTextMsg = Left("If IsCheck(i) And IsCheck(i + 1) Then" & String(50, " "), 50) & ":" & ClsTimerMM.ElapsedTime & vbCrLf
'************************
ClsTimerMM.SetStartDate
For i = 0 To lngMax
If IsCheck(i) Then
If IsCheck(i + 1) Then
End If
End If
Next
strTextMsg = strTextMsg & Left("If IsCheck(i) Then If IsCheck(i + 1) Then" & String(50, " "), 50) & ":" & ClsTimerMM.ElapsedTime & vbCrLf
'************************
Me.txtDATA.Value = strTextMsg
Set ClsTimerMM = Nothing
Private Function IsCheck(ByVal intChk As Long) As Boolean IsCheck = (intChk Mod 2 = 0) End Function
0 件のコメント:
コメントを投稿