|
|
|
| Author Details |
|---|
| All Tutorials by vbtutor |
1 2 [Next] [Last Page]
|
|---|
There are many types of data we come across in our daily life. For example, we need to handle data such as names, addresses, money, date, stock quotes, statistics and etc everyday. Similarly in Visual Basic, we are also going to deal with these kinds of data. However, to be more systematic, VB divides data into different types.
5.1 Types of Visual Basic Data
5.1.1 Numeric Data
Numeric data are data that consists of numbers, which can be computed mathematically with various standard operators such as add, minus, multiply, divide and so on. In Visual Basic, the numeric data are divided into 7 types, they are summarized in Table 5.1
Table 5.1: Numeric Data Types
| | Hits:109 Rate: 0.0(out of 5) Vote:0 Submit Date :2006-03-27 Rate It | Error | Review | | | Category: Home > Visual Basic > Introduction to Visual Basic |
|
|
|---|
Working With Controls
Learn how to work with controls in VB.
In lesson 2, you have learned how to enter the program code and run the sample VB programs but without much understanding about the logics of VB programming. Now, let’s get down learning a few basic rules about writing the VB program code.
Each control or object in VB can usually run many kinds of events or procedures; these events are listed in the dropdown list in the code window that is displayed when you double-click on an object and click on the procedures’ box(refer to Figure 2.3). Among the events are loading a form, clicking of a command button, pressing a key on the keyboard or dragging an object and etc. For each event, you need to write an event procedure so that an action or a series of actions can be performed.
To start writing an event procedure, you need to double-click an object. For example, if you want to write an event procedure when a user clicks a command button, you double-click on the command button and an event procedure will appear as shown in Figure 2.1. It takes the following format:
Private Sub Command1_Click
(Key in your program code here)
| | Hits:104 Rate: 0.0(out of 5) Vote:0 Submit Date :2006-03-27 Rate It | Error | Review | | | Category: Home > Visual Basic > Introduction to Visual Basic |
|
|
|---|
Controlling Program Flow
To control the VB program flow, we can use various conditional operators.
To control the VB program flow, we can use various conditional operators. Basically, they resemble mathematical operators. Conditional operators are very powerful tools, they let the VB program compare data values and then decide what action to take, whether to execute a program or terminate the program and etc. These operators are shown in Table 7.1.
| | Hits:100 Rate: 0.0(out of 5) Vote:0 Submit Date :2006-03-27 Rate It | Error | Review | | | Category: Home > Visual Basic > Introduction to Visual Basic |
|
|
|---|
More on Program Control
If you have a lot of conditional statements, using If..Then..Else could be very messy.
If you have a lot of conditional statements, using If..Then..Else could be very messy. For multiple conditional statements, it is better to use Select Case
The format is :
Select Case expression
Case value1
Block of one or more VB statements
Case value2
Block of one or more VB Statements
Case value3
Block of one or more VB statements
Case value4
| | Hits:103 Rate: 0.0(out of 5) Vote:0 Submit Date :2006-03-27 Rate It | Error | Review | | | Category: Home > Visual Basic > Introduction to Visual Basic |
|
|
|---|
Looping
Visual Basic allows a procedure to be repeated as many times as long as the processor could support. This is generally called looping.
Visual Basic allows a procedure to be repeated as many times as long as the processor could support. This is generally called looping .
9.1 Do Loop
The format are
a) Do While condition
Block of one or more VB statements
Loop
b) Do
Block of one or more VB statements
Loop While condition
c) Do Until condition
Block of one or more VB statements
Loop
| | Hits:103 Rate: 0.0(out of 5) Vote:0 Submit Date :2006-03-27 Rate It | Error | Review | | | Category: Home > Visual Basic > Introduction to Visual Basic |
|
|
|---|
Introduction to VB Function (Part 1)
Functions are similar to normal procedures but the main purpose of the functions is to accept certain inputs and pass them on to the main program to finish the execution. They are two types of function, the built-in functions(or internal functions) and the functions created by the programmers
| | Hits:112 Rate: 0.0(out of 5) Vote:0 Submit Date :2006-03-27 Rate It | Error | Review | | | Category: Home > Visual Basic > Introduction to Visual Basic |
|
|
|---|
Creating VB Function For MS Excel
Start using your VB knowledge in MS Excel.
You can create your own functions to supplement the built-in functions in Microsoft Excel spreadsheet which are quite limited. These functions could be very useful and powerful if you know how to program them properly. One main reason we need to create user defined functions is to enable us to customize our spreadsheet environment for individual needs. For example, we might need a function that could calculate commissions payment based on the sales volume, which is quite difficult if not impossible by using the built-in function alone. Lets look at the table below:
| | Hits:93 Rate: 0.0(out of 5) Vote:0 Submit Date :2006-03-27 Rate It | Error | Review | | | Category: Home > Visual Basic > Introduction to Visual Basic |
|
|
|
|
|
|
|
|