Just so you know:
If performance is an issue at all for you, NEVER use Immediate If statements! They take at least 7.6 times as long to process as regular If Then statements.
If you don't believe me, try this...
Start a new project, paste this code into the form's code window, and run the project:
I just thought you guys might be interested...Code:Option Explicit Private Sub Form_Load() Dim StartTime As Double 'Stores time at start of test Dim EndTime As Double 'Stores time at end of test Dim Result As Boolean 'Holds result of IIf Dim nCounter As Long 'Counter to run test 1 million times 'Show form, tell user to wait Me.Show Print Print " Please wait while running tests..." Print DoEvents '********************' ' Immediate If Test: ' '********************' 'Get start time for IIf test StartTime = CDbl(Timer) 'Run IIf 1 million times For nCounter = 1 To 1000000 Result = IIf(True, True, False) Next nCounter 'Get end time for IIf test EndTime = CDbl(Timer) 'Print difference between start time and end time Print " Time for IIf: " & EndTime - StartTime Print '********************' ' If/Then Test: ' '********************' 'Get start time for If/Then test StartTime = CDbl(Timer) 'Run If/Then 1 million times For nCounter = 1 To 1000000 If True Then Result = True Else Result = False End If Next nCounter 'Get end time for If/Then test EndTime = CDbl(Timer) 'Print difference between start time and end time Print " Time for If/Then: " & EndTime - StartTime End Sub
~seaweed




Reply With Quote