a
> iresp = msgbox("bla bla bla",vbyesnocancel)
>
> iresp need to be integer its lost of memory using long,
'======================================
er, what do you mean?
The VBA.VbMsgBoxResult ARE constants of type LONG, not integers.
1. Type LONG is actually optimized
2. The Message Box ALREADY returns a LONG, so why convert it to an Integer?
This is actually more of a waste. And once the proceedure is finished, what
happens to the memory allocated to this local variable?
'======================================
> ok for the
> error number
> but not for a return value from messagebox, i think argusy just mix up
> the 2 values.
'======================================
Yes, that is true, the one doesn't have anything to do with the other.
The Err.Number does returns a type LONG.
I would stick -214746259 into a CONSTANT (not a variable) so you know what
it is later:
Const cERR_ADO_SOMENAME AS Long = -214746259
Then in the Select Case use:
Case cERR_ADO_SOMENAME
'======================================
> even if your case your not storing the error number in a variable u
> jsut use the normal
> error variable so err.number here
>
> 'instead of select case try with if, i dont trust your case cancel
> thing
Case Cancel was obviously a typo and wrongly defined
> if iresp = 7 then 'this is no
> if iresp = 6 then 'this is yes
[quoted text clipped - 7 lines]
> and vbno its cumthign like 0 or -1, long tiem i havent use it but try
> with those number
'======================================
Using the predefined constants makes the code much more readable, and there
is absolutely no disadvantage in using it compared to a hard-coded numer in
this case.
What do you think happens to those constants when the code is compiled?
'======================================
I ran the same code but changing the "Cancel" to vbCancel", and using an "On
Error Goto OKErr" statement at the top, and then right after that an
err.raise with the same error number.
Works fine.
Jim, are you saying that when the MsgBox in the Case Else comes open, the
error number is -214746259?
Put a msgbox or Debug.? statement at the start of the error handler with the
err.number being returned. Make sure it is there correct and the error
handler is not being called twice, or something else in the error handler is
not messing things up.
Also, I wouldn't do the Case vbYes that way.