View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Hari Prasadh Hari Prasadh is offline
external usenet poster
 
Posts: 63
Default Immediate window - Compile error

Hi Bob,

Thnx for your post. Now am able to get the results.

you have a Debug.Print statement in there, so the print command (?) is not
needed

Initially I thought that -- ? -- and -- Debug.Print -- are synonymous. To
check the same, I tried the following :-

1) ? for i= LBound(arrWords) To UBound(arrWords): arrWords(i) :Next i
I again got a compile error : expected expression

2) for i= LBound(arrWords) To UBound(arrWords): Debug.Print
arrWords(i) :Next i
No error and correct results.

So for some time I was at my wit's end. Then I read very closely your
statement regarding -- You are trying to run some code, not check what a
variable or a statement returns.-- and
things became clearer.

Thanks a lot,
Hari
India


"Bob Phillips" wrote in message
...
Hari,

Have to say I disagree with Rob, I think the immediate window is great for
debuggingh. But you have to use it correctly as with all things, and you
have a Debug.Print statemen t in there, so the print command (?) is not
needed,. You are trying to run some code, not check what a variable or a
statement returns.

Just do

For N= LBound(arrWords) To UBound(arrWords): Debug.Print arrWords(N) :
Next N

make sure N is defined in your code, as this construct is invalid
unfortunately

Dim N :For N= LBound(arrWords) To UBound(arrWords): Debug.Print
arrWords(N)
: Next N

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Hari Prasadh" wrote in message
...
Hi,

Im in the middle of executing code. I have put a break point just after

the
code has Read through the values in an Array called - arrwords.

I wanted to check whether the reading of array has been done properly, so
opened up the immediate window (Ctrl + G)
and wrote the following as it is (Stole from Chip's site)

? For N= LBound(arrWords) To UBound(arrWords): Debug.Print arrWords(N) :
Next N

I get a -- compile error : expected expression


But if i read through the array element by element then I dont get any
error.

? arrwords(4)
microsoft
? arrwords(3)
basic
? arrwords(2)
visual
? arrwords(1)
objects
? arrwords(0)
net

What am I doing wrong in the method of combining several lines of code in

to
one single line of code.

Thanks a lot,
Hari
India