Forum Moderators: open
My code is:
If (Err.Number <> 0) Then
Err.Clear
Dim x_min, x_max, xdiff
x_min = myfunction()’ value is -600 in both cases
x_max = myfunction()’ value is +600 in both cases
MsgBox("x_max = "& x_max & " and x_min = " & x_min) ‘prints same in both the cases ie 600 & -600
xdiff = x_max - x_min
MsgBox( xdiff ) ‘ prints 1200 in normal case, no value in the abnormal case
MsgBox("Error number after xdiff = " & Err.Number) ‘ prints 0 in normal case, 6 in the abnormal case
x_min and x_max is same for both the cases.
Can anybody help with any suggestions?
Thanks in advance,
JJ
Thanks v much for the feedback.
The error happens only when I call xdiff = x_max - x_min (there is no division). Until there, Err.Number value is zero. After this call Err.Number becomes 6.
This happens only when my application's particular window (graphic) opened and minimized, otherwise it works fine.
Regards,
JJ
Here if I assign values to x_min and x_max in the problem scenario, it works fine. When I get values using myfunction and then subtract like xdiff = x_max - x_min, the error pops up.
The confusing thing is, it prints the value correctly in the problem scenario before subtract (ie 600 & -600).
Step that prints values as shown below:
MsgBox("x_max = "& x_max & " and x_min = " & x_min) ‘prints same in both the cases ie 600 & -600