ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   vba doesn't trap errors? (https://www.excelbanter.com/excel-programming/306468-vba-doesnt-trap-errors.html)

bbxrider[_2_]

vba doesn't trap errors?
 
excel 2000/vba

i had some code like this:
select case passedVariable
case "someText" or someVariable & "someText"
but no matter what value was passed the above case always executed!!!

so then tried it in vb6.0 and the 'or' statement generated a type mismatch
error

so then in the vba code i tried
case "someText" , someVariable & "someText"
replacing the 'or' with the ',' (comma) seems to work ok

so it seems the bad syntax of using 'or' in the case statement just caused
faulty program execution instead of trapping an error????

if this is so, is there some way to turn on error trapping, or test to find
syntax and/or other programming errors



Myrna Larson

vba doesn't trap errors?
 
I am using Excel 2002, and your bad line would not compile for me. I got a
"type mismatch" error. (VBA's OR is a bit-wise OR, and it works only on
numeric variables.)

On Mon, 9 Aug 2004 18:40:53 -0700, "bbxrider" wrote:

excel 2000/vba

i had some code like this:
select case passedVariable
case "someText" or someVariable & "someText"
but no matter what value was passed the above case always executed!!!

so then tried it in vb6.0 and the 'or' statement generated a type mismatch
error

so then in the vba code i tried
case "someText" , someVariable & "someText"
replacing the 'or' with the ',' (comma) seems to work ok

so it seems the bad syntax of using 'or' in the case statement just caused
faulty program execution instead of trapping an error????

if this is so, is there some way to turn on error trapping, or test to find
syntax and/or other programming errors




All times are GMT +1. The time now is 05:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com