VB2017 VB2015 VB2013 VB2012 VB2010 VB2008 VB6 VB Sample Codes 中文VB About Us

Lesson 1: Introduction

1.1 The Background

Visual Basic 2008 is the version of Visual Basic launched by Microsoft in 2008. Visual Basic 2008 is almost similar to Visual Basic 2005 but it has added many new features. Visual Basic 2008 is a full fledged Object-Oriented Programming(OOP) Language. However, you don't have to know OOP to learn VB2008. In fact, if you are familiar with Visual Basic 6, you can learn VB2008 effortlessly because the syntaxes and interface are similar. Visual Basic 2008 Express Edition is available free for download from the Microsoft site. (OOP will be explained in lesson 4).

1.2 Visual Basic 2008 IDE

The Integrated Development Environment when you launch Visual Basic 2008 Express is shown in Figure 1.1 below. The IDE consists of a few panes, namely:

Figure 1.1: Visual Basic 2008 IDE

1.3 Creating First Application

To start creating your first application, you need to click on file and select new project. The following VB2008 New Project dialog box will appear, as shown in Figure 1.2.

Figure 1.2

The dialog box offers you five types of projects that you can create. As we are going to learn to create windows Applications, we will select Windows Forms Application

At the bottom of this dialog box, you can change the default project name WindowsApplication1 to some other name you like, for exampe, MyFirstProgram. After you have renamed the project, click OK to continue. The following IDE Windows will appear, it is almost similar to Visual Basic 6. It consists of an empty form, the common controls toolbox, the solution explorer and the properties, as shwon in Figure 1.3

Figure 1.3

Now we will show you how to create your first program. First of all, drag one common button into the form and change its default name to calculate, as shown in Figure 1.4

Figure 1.4

Next, click on the calculate button and key in the following code at the source code window(Figure 1.5) as shown below

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim num1, num2, sum As Single
num1 = 100
num2 = 200
sum = num1 + num2
MsgBox(" The Sum of " & num1 & " and " & num2 & " is " & sum)

End Sub

Figure 1.5

Now run your first application! And you can see the follow message box showing the sum of two numbers,as shown in Figure 1.6

Figure 1.6

Copyright©2008 Dr.Liew Voon Kiong. All rights reserved |Contact|Privacy Policy