So-net無料ブログ作成

ObjectがNothingかどうか [VB]

'As Objectで作った変数の比較方法を忘れてたんでメモ書き

If Object Is Nothing Then
    'エラー処理
Else
    '通常処理
End If

GetTickCount()より精密に時間を計りたいとき [VB]

Public Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long
Public Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long

Dim curStartTime As Currency
Dim curEndTime As Currency
Dim curFreq As Currency

Call QueryPerformanceFrequency(curFreq)
Call QueryPerformanceCounter(curStartTime)

'何か処理

Call QueryPerformanceCounter(curEndTime)
'ミリ秒で出力
Debug.Print CLng((curEndTime - curStartTime) / curFreq * 1000)