ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Immediate window - Compile error (https://www.excelbanter.com/excel-programming/321963-immediate-window-compile-error.html)

Hari Prasadh

Immediate window - Compile error
 
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



Rob van Gelder[_4_]

Immediate window - Compile error
 
Debugging that way from the Immediate window can be terribly painful.

From the View menu choose Locals Window then expand arrwords.

Another way is to go View | Watch Window
Then from the Debug menu, Add Watch
The expression would be arrwords

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"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




Bob Phillips[_6_]

Immediate window - Compile error
 
More easily, if you open the watch window, select arrwords in the code,
click and drag it into the watch window. As Rob says, you can click the +
sign then and see all the values.

--

HTH

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


"Rob van Gelder" wrote in message
...
Debugging that way from the Immediate window can be terribly painful.

From the View menu choose Locals Window then expand arrwords.

Another way is to go View | Watch Window
Then from the Debug menu, Add Watch
The expression would be arrwords

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"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






Bob Phillips[_6_]

Immediate window - Compile error
 
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





Hari Prasadh

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








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

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