How do I compile a .vb file?

GreyArea

New member
Joined
May 14, 2009
Messages
3
Programming Experience
Beginner
I'm trying VB.Net for the first time, and I must say, after spending two hours pulling my hair out (literally!) and trying one thing after another, I am severely disheartened. I just want to compile a simple .vb file.

I used notepad to create a helloworld file. Then my problems started. The book I'm using told me to use a command prompt, and enter:

vbc helloworld.vb

No dice, though. The vbc command was kicked out by the command prompt. I installed Microsoft Visual Basic 2008, and tried again. No dice. Double checked to make sure I had all my updates - check, but still nothing. So I just went ahead and double clicked the the helloworld.vb file. It displayed the text, but still didn't compile, and it wouldn't even allow me to debug it.

I'm at a loss. Please, just tell me how to compile my code. I don't want to make a project, I don't want to debug my code, I don't want any fancy GUI - I just want to compile a good, old-fashioned console application, and then run it on the command line. Please help me.

Thank you for your time.
 
Start VB. Create new project. Choose Console Application and name it. Wait a second. Double click module1.vb. Enter your code in the sub main() part. press CTRL-SHIFT-B.

In case you want to start the compiler directly. Here ist the line from my output window:

C:\WINDOWS\Microsoft.NET\Framework\v3.5\Vbc.exe /noconfig /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Generic,System.Data,System.Diagnostics,System.Linq,System.Xml.Linq /optioncompare:Binary /optionexplicit+ /optionstrict:custom /nowarn:42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 /optioninfer+ /rootnamespace:ConsoleApplication2 /doc:eek:bj\Release\ConsoleApplication2.xml /define:"CONFIG=\"Release\",TRACE=-1,_MyType=\"Console\",PLATFORM=\"AnyCPU\"" /reference:"C:\Programme\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll","C:\Programme\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll",C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Deployment.dll,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll,"C:\Programme\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /main:ConsoleApplication2.Module1 /debug:pdbonly /filealign:512 /optimize+ /out:eek:bj\Release\ConsoleApplication2.exe /resource:eek:bj\Release\ConsoleApplication2.Resources.resources /target:exe Module1.vb "My Project\AssemblyInfo.vb" "My Project\Application.Designer.vb" "My Project\Resources.Designer.vb" "My Project\Settings.Designer.vb"

jep. I prefer to use the IDE ;)
 
I don't want to create a project though. I already have my project; it's a single text file, made in notepad (well, Notepad++, technically), named helloworld.vb. Now I want to compile it. If I can do that through the IDE, again, without creating a new project, fine, but the textbook I'm using said I should be able to go to the command line (Run, cmd), type "vbc helloworld.vb", and have it compile. In the example, the compiler then creates a helloworld.exe file, which can be run through the command line as well. Either way, I shouldn't have to create a new project in the IDE, or use a rather long command line entry.

Thank you for your assistance.
 
You don't normally compile a single file like that with .Net since the IDE, and creating a project is very simple and usually much quicker than Notepad (or similar)

But this article should help ya some: .NET Assemblies
 
Thank you, that article gave me the tips I needed to compile a single file.

The reason I didn't want to do a project was so I could get used to doing things manually, to the extent possible. I'd rather learn the hard way, and then do things the easy way, as opposed to the other way around. ;)

Thanks again.
 
The reason I didn't want to do a project was so I could get used to doing things manually, to the extent possible. I'd rather learn the hard way.
The question might arise, why you want to do so and esp. why you use VISUAL Basic for this. You can do console apps with VB, but that's not what VB was meant for (remember that even a 5k console app would require the xxx MB FW to be installed - if you use the latest 3.5). If you like it hard and pure, you might prefer any C compiler, which could create "static" code. But even hardcore C programmers probably prefer to use a "real" code-editor (at least use something with syntax highlighting) or even an IDE like Eclipse for example.

Rather than trying to be able to write code with a tool that is not meant for it, I'd probably try to write "good" code with tools that help as best as possible in this task.
 
I very much agree, if you have any interest in Visual Basic you should first learn how to use the Visual Studio and the visual tools thereof. Get used to the idea that using tools makes life easier.
 

Latest posts

Back
Top