Home All Groups Group Topic Archive Search About

This Simple 2-Line Program Generates An Error! Why?

Author
1 Jul 2005 5:17 PM
Eric Robinson
I created a new Windows Application project in VB 2003. Aside from the
Windows generated code, this is all I added to the form:

Dim a as String
a="foo"

Believe it or not, the second line generates an error. VB underlines the "a"
with the message "Declaration Expected."

The same code compiles fine on someone else's computer.

Can anyone help me understand this?

--Eric

Author
1 Jul 2005 5:21 PM
Herfried K. Wagner [MVP]
"Eric Robinson" <eric @ pmcipa..{com}> schrieb:
>I created a new Windows Application project in VB 2003. Aside from the
>Windows generated code, this is all I added to the form:
>
> Dim a as String
> a="foo"
>
> Believe it or not, the second line generates an error. VB underlines the
> "a" with the message "Declaration Expected."
>
> The same code compiles fine on someone else's computer.

Make sure you added the code to a procedure.  When adding the code to the
class directly you'll receive the above message.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
1 Jul 2005 5:23 PM
Eric Robinson
Yargh. Naturally. Sorry.

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:uyppDFmfFHA.2840@tk2msftngp13.phx.gbl...
> "Eric Robinson" <eric @ pmcipa..{com}> schrieb:
>>I created a new Windows Application project in VB 2003. Aside from the
>>Windows generated code, this is all I added to the form:
>>
>> Dim a as String
>> a="foo"
>>
>> Believe it or not, the second line generates an error. VB underlines the
>> "a" with the message "Declaration Expected."
>>
>> The same code compiles fine on someone else's computer.
>
> Make sure you added the code to a procedure.  When adding the code to the
> class directly you'll receive the above message.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
1 Jul 2005 5:21 PM
Al Reid
Show quote Hide quote
"Eric Robinson" <eric @ pmcipa..{com}> wrote in message news:qUexe.3954$Si3.3091@fe06.lga...
> I created a new Windows Application project in VB 2003. Aside from the
> Windows generated code, this is all I added to the form:
>
> Dim a as String
> a="foo"
>
> Believe it or not, the second line generates an error. VB underlines the "a"
> with the message "Declaration Expected."
>
> The same code compiles fine on someone else's computer.
>
> Can anyone help me understand this?
>
> --Eric
>
>

And you put those two lines where?  In the declarations section,  in a sub or function, an event handler?