PDA

View Full Version : Solved: VBA error



Ismael
10-28-2005, 02:47 AM
Hi to all in the forum,

I'm trying to understand some things in VBA, and I by a book to take the first steps.

Now regarding an example of the book, when I execute the instruction case select, I obtain a error message, you guys can see this error in attached file.

I don't now why this is happens because I done exactly what is in the book.

So, if any of you guys can take a look at this, I really appreciate.

Best regards,

Ismael

TonyJollans
10-28-2005, 03:02 AM
Hi Ismael,

Are you quite sure that's what's in the book? If so, what book is it?

To test for a range in a case stetment use ..

Case 500 To 1000

Ismael
10-28-2005, 03:34 AM
Hi Tony,

Yes what I type is exactly what is in the book.
I have scan the pages, you can see this on attach.

If this is uncorrect, please tell me how can I solve this problem, because in the book exist very similar codes.

Best regards,

Ismael

TonyJollans
10-28-2005, 04:57 AM
Well, the book is wrong!

Correct code is like this: Select Case bruto
Case 500 To 999
irs = bruto * irs_escal?o_1
Case 1000 To 1499
irs = bruto * irs_escal?o_2
Case >= 1500
irs = bruto * irs_escal?o_3
End Select

The description in Help is not the easiest to understand. And, indeed, the implementation isn't sparkling (what you copied from the book really ought to work IMHO). The fact is that compound conditions do not work in Case statements and you have to code round it - and the book really should know that.