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

  • Thread starter Thread starter Eric Robinson
  • Start date Start date
E

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
 
Eric Robinson said:
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.
 
Eric Robinson said:
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?
 
Yargh. Naturally. Sorry.

Herfried K. Wagner said:
Make sure you added the code to a procedure. When adding the code to the
class directly you'll receive the above message.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top