Free Ebook: Visual Basic 2008 Recipes A Problem-Solution Approach

Powered By

Free XML Skins for Blogger

Powered by Blogger

Thursday, July 3, 2008

Visual Basic 2008 Recipes A Problem-Solution Approach

Sometimes you meet requirement to cipher a difficulty and intend on with your work. To that end, Visual Basic 2008 Recipes is a publication of applicatory solutions for laboring VB .NET programmers. Create instance for the more engrossing aspects of your VB .NET send by finding ordinary problems with the applicatory solutions and mountain of cipher examples in this book. Important newborn .NET 3.5 technologies, much as Windows Presentation Framework (WPF) and Language Integrated Query (LINQ), are covered, and apiece chapter addresses a limited difficulty domain, including database access, multimedia, XML manipulation, networking, and security. The cipher is liberated to download so you crapper ingest the recipes immediately.

* Take plus of quality, ready–made solutions to ordinary Visual Basic planning problems.
* Avoid the dullness of having to reinvent the wheel. Focus instead on the more engrossing problems limited to your application.
* Learn from and be inspired by what the authors hit done. Use their impact as stepping stones to cipher modify more Byzantine problems.



What you’ll learn

* Cleanly removed user–interface system from playing system finished the ingest of .NET 3.5’s WPF.
* Store accumulation to and regain accumulation from your relational database using LINQ.
* Manipulate XML accumulation using LINQ.
* Make your programs dynamically configurable finished the prudent covering of reflection.
* Take plus of binary mainframe cores by composition multithreaded applications.
* Integrate transmission into your Visual Basic projects.

Who is this aggregation for?

Visual Basic 2008 Recipes is cursive for Visual Basic developers who hit at small whatever undergo in nonindustrial Visual Basic solutions. The aggregation contains recipes attractive to grey finished modern developers.

====================================================================

Create a Console Application from the Command Line
Problem
You need to use the VB .NET command-line compiler to build an application that does not require
a Windows graphical user interface (GUI) but instead displays output to, and reads input from, the
Windows command prompt (console).
Solution
In one of your classes, ensure you implement a Shared method named Main with one of the following
signatures:

Public Shared Sub Main()
End Sub
Public Shared Sub Main(ByVal args As String())
End Sub
Public Shared Function Main() As Integer
End Sub
Public Shared Function Main(ByVal args As String()) As Integer
End Sub

Build your application using the VB .NET compiler (vbc.exe) by running the following command
(where HelloWorld.vb is the name of your source code file):

vbc /target:exe HelloWorld.vb
------------------------------------------------------------------------------------------------
Note If you own Visual Studio, you will most often use the Console Application project template to create new
console applications. However, for small applications, it is often just as easy to use the command-line compiler. It
is also useful to know how to build console applications from the command line if you are ever working on a machine
without Visual Studio and want to create a quick utility to automate some task.
-------------------------------------------------------------------------------------------------
How It Works
By default, the VB .NET compiler will build a console application unless you specify otherwise. For
this reason, it’s not necessary to specify the /target:exe switch, but doing so makes your intention
clearer, which is useful if you are creating build scripts that will be used by others or will be used
repeatedly over a period of time.
To build a console application consisting of more than one source code file, you must specify all
the source files as arguments to the compiler. For example, the following command builds an application
named MyFirstApp.exe from two source files named HelloWorld.vb and ConsoleUtils.vb:

vbc /target:exe /main:HelloWorld /out:MyFirstApp.exe HelloWorld.vb ConsoleUtils.vb

The /out switch allows you to specify the name of the compiled assembly. Otherwise, the assembly
is named after the first source file listed—HelloWorld.vb in the example. If classes in both the HelloWorld
and ConsoleUtils files contain Main methods, the compiler cannot automatically determine which
method represents the correct entry point for the assembly. Therefore, you must use the compiler’s
/main switch to identify the name of the class that contains the correct entry point for your application.
When using the /main switch, you must provide the fully qualified class name (including the
namespace); otherwise, you will receive the following:
-------------------------------------------------------------------------------------------------
vbc : error BC30420: 'Sub Main' was not found in 'HelloWorld'
-------------------------------------------------------------------------------------------------
If you have a lot of VB .NET code source files to compile, you should use a response file. This
simple text file contains the command-line arguments for vbc.exe. When you call vbc.exe, you give
the name of this response file as a single parameter prefixed by the @ character. Here is an example

vbc @commands.rsp

To achieve the equivalent of the previous example, commands.rsp would contain this:

/target:exe/main:HelloWorld/out:MyFirstApp.exe HelloWorld.vb ConsoleUtils.vb

For readability, response files can include comments (using the # character) and can span multiple
lines. The VB .NET compiler also allows you to specify multiple response files by providing multiple parameters that are prefixed with the @ character.

Download Ebook

No comments: