D
Dan
Hoping someone can help me with this problem...
Just for a bit of fun I am running the following code:
Sub TimeTest()
'100 million random numbers, tests, and math operations
Dim x As Long
Dim StartTime As Single
Dim i As Long
x = 0
StartTime = Timer
For i = 1 To 100000000
If Rnd <= 0.5 Then x = x + 1 Else x = x - 1
Next i
MsgBox Timer - StartTime & " seconds"
End Sub
Now, every now and again this throws an error with the following message:
Runtime error '16':
Expression too complex
The debugger indicates the problem lies with this line:
If Rnd <= 0.5 Then x = x + 1 Else x = x - 1
Can anyone suggest why this very simple expression be considered by VBA to
be too complex only some of the time??
Thanks
Dan
Just for a bit of fun I am running the following code:
Sub TimeTest()
'100 million random numbers, tests, and math operations
Dim x As Long
Dim StartTime As Single
Dim i As Long
x = 0
StartTime = Timer
For i = 1 To 100000000
If Rnd <= 0.5 Then x = x + 1 Else x = x - 1
Next i
MsgBox Timer - StartTime & " seconds"
End Sub
Now, every now and again this throws an error with the following message:
Runtime error '16':
Expression too complex
The debugger indicates the problem lies with this line:
If Rnd <= 0.5 Then x = x + 1 Else x = x - 1
Can anyone suggest why this very simple expression be considered by VBA to
be too complex only some of the time??
Thanks
Dan