VB.net program cannot be compiled in command line

L

Lovely Dola

I have the following simple "Hello, world" vb.net program named "prog01.vb" :

Module prog01
sub Main()
MsgBox("Hello, world!")
end sub
end Module

and compile it using vbc.exe as follows:

vbc /reference:Microsoft.VisualBasic.dll prog01.vb

but receive error messages as follows:

prog01.vb(3) : error BC30451: Name 'MsgBox' is not declared.

I have no Visual Studio.NET but use .NET Framework SDK 1.1 instead.
Could anyone pls tell me what's wrong with the program or the
compilation process?
 
J

Jay B. Harlow [MVP - Outlook]

Lovely Dola,
The /reference on the command line only allows you to use the Types
(classes, modules, structures, delegates, and interfaces) within the listed
assembly.

You also need to either give the fully name or import the namespace where
MsgBox is.

Either of the following should work (along with the /reference on the
command line):

Imports Microsoft.VisualBasic
Module prog01
sub Main()
MsgBox("Hello, world!")
end sub
end Module

Module prog01
sub Main()
Microsoft.VisualBasic.Interaction.MsgBox("Hello, world!")
end sub
end Module

Hope this helps
Jay
 

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

Top