ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Help with VBA Error (https://www.excelbanter.com/new-users-excel/414859-help-vba-error.html)

HatStephens

Help with VBA Error
 
Tonight am I attempting to learn VBA and using a tutorial from jlathamsite.com.

It was all going well until I had to type up my first programme (module).

The below code is producing an error which says "Expected: end of statement" and is highlighting raiseToPower as the location.


MsgBox theNumber & " raised to the power of " raiseToPower & " = " theResult


If it helps theNumber and raiseToPower are both Dim and are Integers.

Thanks,

Hat

Ron Rosenfeld[_2_]

Help with VBA Error
 
On Sun, 26 Feb 2012 00:54:09 +0000, HatStephens wrote:


Tonight am I attempting to learn VBA and using a tutorial from
jlathamsite.com.

It was all going well until I had to type up my first programme
(module).

The below code is producing an error which says "Expected: end of
statement" and is highlighting raiseToPower as the location.


MsgBox theNumber & " raised to the power of " raiseToPower & " = "
theResult


If it helps theNumber and raiseToPower are both Dim and are Integers.

Thanks,

Hat


You omitted an ampersand after the second quote mark. So the compiler thinks it should stop at that second quote mark, but since you have stuff on the line after that, which is not a comment, the error message is produced.

MsgBox theNumber & " raised to the power of " & raiseToPower & " = " & theResult

Stan Brown

Help with VBA Error
 
On Sun, 26 Feb 2012 00:54:09 +0000, HatStephens wrote:
MsgBox theNumber & " raised to the power of " raiseToPower & " = "
theResult


You forgot the ampersand before theResult.

(I'm assuming in the original this was all on one line.)

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com
Shikata ga nai...

HatStephens

Thank you both so much!! I'm starting to get the hang of this.....well a little!

I'm sure i'll be posting here regularly!


All times are GMT +1. The time now is 01:22 AM.

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