Tuesday, December 30, 2008

New Lesson: Handling Graphics in Visual Basic 6

Graphics is a very important part of visual basic programming as an attractive interface will be appealing to the users. In the old BASIC, drawing and designing graphics are considered as difficult jobs, as they have to be programmed line by line in a text-based environment. However, in Visual Basic, these jobs have been made easy. There are four basic controls in VB that you can use to draw graphics on your form: the line control, the shape control, the image box and the picture box.

Please learn more about graphics in our newest lesson by clicking the link below:


Sunday, December 28, 2008

Reorganization of vbtutor content page

We have had a major reorganization of the vbtutor content page. We have also corrected some errors and bad links. Now it is easier to navigate. Log on to


to see the changes.

Compiling and Distributing Your VB Programs

Once your have completed a VB program, you can compile the program to run as a standalone windows application, without having to launch the Visual Basic IDE. However, before you compile your program, you have to debug your program to make sure it is errors free. Once the program is compiled into an EXE file (executable file), you can not debug it anymore. If you wish to do so, you have to correct the errors and recompile it.

Other than that,
you might want to market your product, either online or offline. This means that you need to create a package that can be distributed to your potential customers. The package created can be distributed using CD ROM, diskette or the Internet. The package will allow the user to install the program to install in the computer with the standard setup routine.

Learn how to compile and distribute your VB programs in our new lesson at:


Tuesday, December 23, 2008

Merry Chritsmas

Merry Christmas to everybody, particularly to our Christian friends! Even if you are not a Christian, I'm sure you still would like to have fun in this festive season.

This year seems to be a particularly cold year, with many places in North America, Europe and East Asia experiencing sub -zero degree temperature, some places even dipped below -20 degree Celsius. I have a daughter who is studying at Drake University, Des Moines, Iowa, and she has hard time adjusting to the severe temperature. She is staying there for winter break and it would take one day for her to fly home across the Pacific Ocean.

For those VB friends who are experiencing severe weather, I hope you can take good care of yourself and your loved ones. And since you will spend more time indoor, why not learn more about VB programming?

Wish everybody good luck and have a great festival!

Friday, December 19, 2008

Reading and Writing Text File in VB2008

To be able to open a file and read the data from a storage unit of a computer, such as a hard drive and able to save the data into the storage unit are important functions of a computer program. In fact, the ability to store, retrieve and modify data makes a computer a powerful tool in database management.

Reading and writing to a text file in VB2008 required the use of the StreamReader class and the StreamWriter class respectively. StreamReader is a tool that enables the streaming of data by moving it from one location to another so that it can be read by the user. For example, it allows the user to read a text file that is stored in a hard drive. On the other hand, the StreamWriter class is a tool that can write data input by the use to a storage device such as the hard drive.

To learn further, please view our new Vb2008 lesson at:


Monday, December 15, 2008

Counting items in a Combo Box

In Visual Basic, the combo box is a control that can store a list of items. Is it possible to count the number of items that is stored in the combo box? The answer is yes. The keyword to use is the ListCount property. However, in order to count the items according to categories, we have to use the For....Next loop to accomplish the task.

I have written a program to count the number of students who score A, B, C and D respectively. In this program, the user click the "Add Item" button to enter the grades from an Input Box. After entering all the grades, the user can get the statistics by pressing the 'Count" button.

The code is as follows:

Private Sub Command1_Click()
Dim item As String

item = InputBox("Enter an item")

Combo1.AddItem item

End Sub

Private Sub Command2_Click()
Dim count, i As Integer
Dim item1, item2, item3, item4 As Variant

count = Combo1.ListCount

For i = 0 To count

Combo1.Text = Combo1.List(i)

If Combo1.Text = "A" Then
item1 = item1 + 1
ElseIf Combo1.Text = "B" Then
item2 = item2 + 1
ElseIf Combo1.Text = "C" Then
item3 = item3 + 1
ElseIf Combo1.Text = "D" Then
item4 = item4 + 1
End If

Lbl_A.Caption = item1
Lbl_B.Caption = item2
Lbl_C.Caption = item3
Lbl_D.Caption = item4

End Sub

The Output Screen:

Friday, December 12, 2008

Errors Handling in Visual Basic 2008

Dear Readers

I have written about errors handling in Visual Basic 6 the other day. Now, I have written errors handling in VB2008. In this new lesson, you will learn how to use the Try...Catch....End try statement to manage exceptions or errors in a VB2008 program. For detail info, please view


Wednesday, December 10, 2008

Revamp of my website

Dear Vbtutor.net readers,

I have carried out quite a major revamp to the Vbtutor website. It looks much more streamlined and systematic now. It has also becoming easier to navigate. Please check out the lessons at


Monday, December 8, 2008

Error Handling in Visual Basic

HTML clipboardError handling is an essential procedure in Visual Basic programming because it can help make the program error-free. An error-free program can run smoothly and efficiently, and the user does not have to face all sorts of problems such as program crash or system hang.
ML clipboard

Errors often occur due to incorrect input from the user. For example, the user might make the mistake of attempting to ask the computer to divide a number by zero which will definitely cause system error. Another example is the user might enter a text (string) to a box that is designed to handle only numeric values such as the weight of a person, the computer will not be able to perform arithmetic calculation for text therefore will create an error. These errors are known as synchronous errors.

Learn how to write errors handling procedure in Visual Basic in our new lesson at


Thursday, December 4, 2008

Chinese Visual Basic Tutorial

If you have Chinese friends who is interested in learning Visual Basic programming but can't understand the concepts in English, please ask them to visit the Chinese version of vbtutor.net at


Wednesday, December 3, 2008

Temperature Converter

With winter around and daily temperature change has become a concern for many people especially those who travel a lot. They are constantly checking out temperature readings everyday However, different parts of the world often use different temperature scales, some of them use Fahrenheit and some use Celsius, so the readings can be confusing. Therefore, it is nice if we have a program that can convert Celsius to Fahrenheit and vice versa. And I have done just that using Visual Basic 6. The code is like this:

Private Sub Command1_Click()
Dim cel, Fah As Single
cel = Val(txtC.Text)
Fah = Val(txtF.Text)

If txtC.Text <> "" And txtF = "" Then
Fah = ((9 / 5) * cel + 32)
txtF.Text = Round(Fah, 1)
cel = (5 / 9) * (Fah - 32)
txtC.Text = Round(cel, 1)
End If

End Sub

Private Sub Command2_Click()
txtC.Text = ""
txtF.Text = ""

End Sub

Thursday, November 27, 2008

More SQL keywords in VB6

Another New lesson is added! This lesson teach you how to use more SQL keywords in database queries. You will learn the keywords WHERE for specifying certain criteria to search for data in a table. For details, please refer to


Wednesday, November 26, 2008

Using SQL in Visual Basic 6

I have created another new tutorial lesson. In this lesson, I discuss and demonstrate the use of Structured Query Language (SQL) in Visual Basic 6 environment. You will learn how to use the SQL keywords such as SELECT and FROM to look for certain data in a database. Click the link below to learn about SQL now.


Saturday, November 22, 2008

DataGrid Control

I have included a new lesson related to database management. In the previous chapters, we use textboxes to display data by connecting them to a database via Microsoft ADO data Control 6.0. The textbox is not the only control that can display data from a database, many other controls in Visual Basic can display data. One of the them is the DataGrid control. DataGrid control can be used to display the entire table of a recordset of a database. It allows users to view and edit the data. Please click on Lesson 21(b) to view the latest lesson.

Wednesday, October 22, 2008

Basic Programming- 30 years ago

Visual Basic have come a long way since the invention of the BASIC language. When I first started learning BASIC back in the late 70's of the last century, personal computers were not popular yet. I remembered I was using the punch card machine to key in the program code, each card represent a program statement. So, for a long program, we have to use many cards. We don't get the output immediately, what we do was to send our cards to the processing center when the technicians would feed the cards into the main frame computer. We would only get our printouts the following day . How slow was it! But we never complain, because we were the lucky ones who have access to the computer those days, many people out there were still ignorant about computer. So, see how lucky you are today, you can have a laptop with the computing power matching or better than the old mainframe, and you get your output instantly!

Sunday, October 19, 2008

Financial Crisis Self Help

The financial crisis is getting more and more serious, many financial institutions and banks are going bust and stocks are sinking! So beside doing programming for fun, we should also think of some self-help methods to face the financial crisis. For me, the best way is to earn some money online to supplement our dwindling incomes. I have started a blog to discuss how to make money online, you might find it useful in this critical time. Click on the link below to browse the blog.

Online Business Help Center

Friday, October 10, 2008

Creating a web browser in VB2008

Creating a web browser in Visual Basic 2008 is a relatively easy job. You don't need to type in a lot of complicated procedures. Just follow this link to see how it is done.

Creating a web browser in Vb2008

Saturday, September 13, 2008

Visual Basic Source Code for Download

Good News! Now I have made the source code for most of my sample VB programs available for download. These programs are discussed in my tutorials or the sample programs page. Please click the link below to start downloading the source code. This save you time to key in the code again. However, you might need to change certain settings such as the path of a file.

VB Download Area

Saturday, August 23, 2008

Changing Background and Foreground Color at Run Time for VB6

It is very easy to change background color and foreground color at run time, just use the code below:
Private Sub Form_Load()
Form1.BackColor = vbRed
Form1.ForeColor = vbBlue
Form1.Print "Foreground"
End Sub

Thursday, August 7, 2008

Lesson on Radio Buttons

You have already learned how to use the check boxes in VB2008 tutorial, lesson 17. In lesson 18, you will learn how to use another kind of choice selection control, the radio button. You will find out the difference between the radio buttons and the check boxes. Please click on the link below to start learning.


Happy Learning.

Tuesday, August 5, 2008

Using Check Box

The Check box is a very useful control in Visual Basic 2008. It allows the user to select one or more items by checking the check box/check boxes concerned. In lesson 17 of VB2008 tutorial, you will learn how to create a simple shopping cart using the check boxes. Please click the link below to start learning.


Happy Learning.

Tuesday, July 29, 2008

VB2008 -Lesson 16 Formatting date and time

Lessson 16 for VB2008 tutorial is now done. This lesson deals with using the format function to customize the display of time and date in various forms. Please click the link below to view the lesson and start trying them out.


Wednesday, July 23, 2008

VB2008 -Lesson 15 Formatting Functions

It is often useful to format outputs so that they are more presentable and more meaningful. For example, we may want to limit the number of decimal points or we may want to convert a number to percentage form. In this lesson, you will learn how to format output using the format function in VB2008. Please click the link below to browse the lesson.


Happy Learning

Tuesday, July 22, 2008

VB2008_Lesson 14 Math Functions

Vb2008 Lesson 14 is now ready. This lesson mainly discusses the usage of various Math functions such as Rnd, Int, Fix, Round, Log and others. Please click th link below to browse the lesson:


Happy Learning

Saturday, July 19, 2008

VB2008 -Lesson 13 Functions-Part II

We have learned about the basic concept of function as well as the MsgBox and InputBox functions in Lesson 12. I. In fact, I have already shown you a few string manipulation functions in Lesson 8, they are the Len function, the Left function and the Right Function. In this lesson, we will learn other string manipulation functions. Click the link below to start learning.


Thursday, July 17, 2008

VB2008 -Lesson 12 Msg( ) and InputBox( ) Function

I have just done up Vb2008 lesson 12.
In this lesson, you will learn how to use the Msg ( ) and the InputBox ( ) functions. Msg ( ) is used for displaying messages while the InputBox is used for accepting inputs from the user. Please click the link below to browse the lesson.

Happy Learning

Tuesday, July 15, 2008

VB2008 -Lesson 11 Looping

Visual Basic 2008 allows a procedure to be repeated as many times as long as the processor could support. This is generally called looping. To learn more about looping, click the link below to browse lesson 11.


Happy Learning

Sunday, July 13, 2008


VB2008 Lesson 10 is now ready. In this lesson, you will learn about the Select Case structure through some examples. The Select Case structure is extremely useful in handling multiple choice situations. Please click the link below to view the lesson.


Happy Learning

Friday, July 11, 2008


Visual Basic 2008 Tutorial lesson 9 is now ready. It discusses the If...Then...Else statements, Please follow the following link to browse the lesson.


Monday, July 7, 2008

VB2008- Lesson 8

You have learned how to handle and manipulate numeric data in VB2008-Lesson 7. Now, you will learn how to manipulated non-numeric data particularly string data type. So, please view the link below to browse VB2008-Lesson 8.


Happy Learning

Wednesday, July 2, 2008

What is VBA ?

What is VBA? Many of you might have done VBA but yet many others might not know what it is. So let me explain what it is. VBA stands for Visual Basic for Applications. Visual Basic is built into every Microsoft Office applications such as MS Excel, MS Words, MS PowerPoint, MS Access and etc. Using VBA, we can build custom applications for the all the above MS Office applications. Although the Microsoft Office applications themselves are already powerful enough, VBA can extend their capabilities.

For those of you who have already purchased a copy of Microsoft Office , you can actually learn Visual Basic without having to spend money to purchase another copy of Visual Basic. If you are interested to learn VBA, click the link below to learn about VBA for MS Excel. Theses lessons were prepared by us and we will add more lessons later.


Happy Learning!

Saturday, June 28, 2008

Visual Basic 2008 -Lesson 7

Performing mathematical operations in VB2008 is very easy. You can create all sorts of useful mathematical programs such as BMI calculator that can help you to compute your own BMI. All these are discussed in the chapter 7 of VB2008 tutorial. Please click the link below to view the lesson.


Happy Learning

Wednesday, June 25, 2008

Visual Basic 2008 -Lesson 6

Visual Basic 2008 lesson 6 is ready. Please click the link below to view its contents. It is about VB2008 data types.


Tuesday, June 24, 2008

Lesson 5 Updates

I have just updated lesson5 of Visual Basic tutorial. This lesson is about managing Visual Basic data, some extra information is added today. Please check it out at the link above.

Happy Learning.

VB2008 -Lesson 5

VB2008- Lesson 5 is ready, please click on the link above to view the lesson. In this lesson, I explain the concept of event procedure and how to write VB2008 code in the event procedure. I also continue to explain some concepts of OOP.

Happy Learning

Sunday, June 22, 2008

VB2008 -Lesson 4

VB2008 Lesson 4 is now ready. Some basic concepts of Object Oriented Programming are discussed in this lesson as VB2008 is a full fledge OOP programming language. Hope you can grasp those concepts.
Happy learning

Saturday, June 21, 2008

Vb2008 - Lesson 3

I have just added VB2008 -lesson 3 to my website. It is about customizing properties in VB2008 . It includes some sample codes that involve changing the form's background and foreground colors at design time and at run time. Please click the link above to check it out.

Friday, June 20, 2008

Lesson 10 updates

I have added additional materials to lesson 10 of Visual Basic tutorial. These are extra sample programs on functions. You can click at the link above to access them.

I have also started two lessons on Visual Basic 2008. You can find the link at the right side bar of www.vbtutor.net. More lessons will be added soon, so check back regularly for updates.

Thank you


Friday, May 9, 2008

Vbtutor updates

I have added quite a lot of materials lately to my website www.vbtutor.net. Among them are

a)My article on how to make money with your personal website.

b) Flash tutorial created by my 13 year-old son Liew Xun. He has done six lessons and he has promised me more lessons will come. Please check back regularly for the updates.

c) Research Guide- This will be a quick guide for undergraduate and postgraduate students to conduct research.