Introduction to Visual Studio 2008

Pulled verbatim from w:Microsoft Visual Studio

Microsoft Visual Studio is an Integrated Development Environment (IDE) from Microsoft. It can be used to develop console and graphical user interface applications along with Windows Forms applications, web sites, web applications, and web services in both native code together with managed code for all platforms supported by Microsoft Windows, Windows Mobile, Windows CE, .NET Framework, .NET Compact Framework and Microsoft Silverlight.

Visual Studio includes a code editor supporting IntelliSense as well as code refactoring. The integrated debugger works both as a source-level debugger and a machine-level debugger. Other built-in tools include a forms designer for building GUI applications, web designer, class designer, and database schema designer. It allows plug-ins to be added that enhance the functionality at almost every level - including adding support for source control systems (like Subversion and Visual SourceSafe) to adding new toolsets like editors and visual designers for domain-specific languages or toolsets for other aspects of the software development lifecycle (like the Team Foundation Server client: Team Explorer).

Introduction

edit

Visual Studio functions as the code editing area, form designer, code validator, compiler and library browser for a software development project. It supports languages by means of language services, which allow any programming language to be supported (to varying degrees) by the code editor and debugger, provided a language-specific service has been authored.

In this course we will be exploring installation, initialization, and basic use of the IDE for the purpose of writing VB.NET software.

Installation

edit

Download

edit

If you have not already, download the 90 day trial of Visual Studio 2008 Professional and .NT Framework 3.5 SP1. As with most development related software installation of these packages (and depending on your system/domain security policy, downloading too) requires at least Local Administrator privileges. Keep in mind that Visual Studio 2008 Professional is about 3.4 GB, so it would be best to start the download and then go off to do something else for a while. Additionally, installing .NET 3.5 and Visual Studio both require a lot of time (Will update this when I do fresh installs).

Install

edit
 
Initial Install Dialog

It really does not matter what order you install these packages in. As .NET framework is used by many programs today, I typically install it well before ever installing Visual Studio.

It is recommended that the MSDN documentation (2nd selection in the screenshot to the right) be installed along with Visual Studio.

 
Install Selection Dialog

If you intend to use the SQL Server 2008 180 Day Trial linked from the course description page, do not install SQL Server 2005 Express. Additionally for the scope of this course, you do not need to install the language runtimes for C++, C# or J#.

Other than the above considerations, there is very little to installing the software. On to the initialization.

Initialize

edit

The first time Visual Studio is run it asks for the user to define the default environment settings. For the purposes of this course, please choose the Visual Basic Development Settings selection and press Start Visual Studio. Note that there is also a check box for viewing RSS material. While this is not important for this course, the news that is downloaded (depending on the default settings you selected) will give information on language specific news (How-tos, tutorials, etc.) or Visual Studio specific news.

Usage

edit

Basic Use

edit

There are several levels of hierarchy in the Visual Studio file saving scheme.

Solutions
Comprised of one or more projects. Typically most solutions start with one project and incorporate more as the application progresses and becomes more sophisticated.
Project
Incorporates one or more Items that all describe actions for a certain operation (i.e. GUI and related logic in one project, SQL server project to handle data interchange, and custom class project from another language to handle ImageList population).
Item
(include but not limited to the following)
 
New project
Form
A window with any number of controls (such as text boxes buttons, list boxes, etc.)
Class
Used to describe a custom class of objects and the properties, methods and events that make them up.
Resource
A file that incorporates any data that the project might need (Often things like images, icons, settings, etc)

Open the IDE and select Create: Project... or File>New Project from the menu. In the New Project Dialog Select Windows Forms Applications and change the name to Hello_World.

Form1.vb is the first Windows Form created by the IDE. On the right side of the screen is the Properties window with all of the Form properties displayed in alphabetical format. On the left side of the screen are two pop out tabs, Server Explorer and Toolbox. Server Explorer allows you to view services, event logs performance counters (most useful with software that writes values to the event log or require services to run.

The toolbox contains controls and structure that will be used to populate forms. Probably 90% of the time you will be using controls in the Common Controls section of the toolbox. These include buttons, check boxes, list boxes, combo boxes, labels, etc. Any one of these items may be drug onto the blank form and dropped there, and then customized (mostly appearance) from the properties window, and have logic code written in the code window to support it's operation.

 
Small blue lines help position the button near other objects.

Example

edit

Lets start with something simple:

  1. Drag a button onto the form.
  2. In the properties window
    1. Change the Text to "Hello World" (do not enter quotes)
    2. Change the Name to "btnHelloWorld"
  3. Double Click on the button
  4. In the code window that opens, type the following code between the Private Sub and End Sub lines
MsgBox("Hello World!" & vbNewLine & "It is a bright new day!")

Assuming you typed the code instead of copy/pasted it, you should have seen a small window pop up as you were typing with suggestions of items you might want to put in. This is Intellisense. It contains the classes, namespaces, methods (functions), properties, events, variables, constants and arguments that are currently accessible. vbNewLine is a constant which equals two characters (Carriage Return and Line Feed) MsgBox pops up a simple Windows dialog box with the text in the parentheses in it and an OK button (more than this, but we will get to that later).

Now, click the green triangular play button or Build>Start Debugging...

The form will load and it will have the button you created in it. Click the button and the message box will pop up with the message in it.

In the next lessons we will look at some of the basics of the Visual Basic language and then create a form that uses some of that information.