|
à
à
à à ! "# $ %& ' "# ( à ! ! à $ % ! %% ! ! ! ! )* à $ ! ! +*,*- ! à $ . ! ( %$
!&)'$ ! "# ! !$ % & $ ' ' %
&/' ! %( %) ! ! %* !+ |!, |& ' - % .$ ! * / * 0 0& *+ & &,& %
* s % &0'! % &&1 ' !
! %( 2 %
* 2 s % s &1'% - ' & %
! $ ! & % 34 % * 56 46 ' 56 7 ! 8 9 0 ' %
( ! s % s % !! $! ! %&1 ' :! & ! $ %
à
Ë
à
s
%
; &1 ' $ $ %
&1 ' !! ! 1 $ ! < &1 ' 0=+ $ $ * %
9 ' &1 ' !$ $ |! ' % ! 1 % ) ! % $ ' !
1 % 1 % ' $ $ % &1 ' !! 1 %
! 1 $ &1 < 9 * % 1 $ &1 ' &1 < + % ,! &1 ' 2 $ %
9 ! * $ ' ! ! % + ' $ % 9 $ 2 $ !
! %
à %
à % $ %* $ ' % > : $ ! :
%$ ' % $ ' %
; ' % * 4 ! '4 '
! % 9 ! $ %
- $ ' % * $ $ = ? $
* ! ! ' % ' % ' ' ! * %
à An Overview à is a high level programming language evolved from the earlier DOS version called BASIC. BASIC means eginners' ll-purpose ymbolic nstruction ode. It is a fairly easy programming language to learn. The codes look a bit like English Language. Different software companies produced different version of BASIC, such as Microsoft QBASIC, QUICKBASIC, GWBASIC ,IBM BASICA and so on. VISUAL BASIC is a VISUAL and events driven Programming Language. These are the main divergence from the old BASIC. In BASIC, programming is done in a text-only environment and the program is executed sequentially. In VISUAL BASIC, programming is done in a graphical environment. Because s may click on a certain object randomly, so each object has to be programmed independently to be able to response to those actions (events). Therefore, a VISUAL BASIC Program is made up of many subprograms, each has its own program codes, and each can be executed independently and at the same time each can be linked together in one way or another
! à
as Standard MicroSoft ³feel´. Title Bar. Status : Design, run, debug. Menu Bar. Pull down menus. Tool Bar. Tool Box. For adding controls. Project Explorer. List project modules. Properties Window. Form Layout.
! à à open an existing project or select a list of recently opened programs ! Standard EXE programs ! "
! à
The Visual Basic Environment consists the following :
# for you to design your application's interface.
! $ which displays the files that are created in your application.
! $ which displays the properties of various controls and objects that are created in your applications.
It also includes a ! that consists of all the controls essential for developing a VB Application. Controls are tools such as text box, command button, label, combo box, picture box, image box, timer and other objects that can be dragged and drawn on a form to perform certain tasks according to the events associated with them.
%
Visual Basic Environment
# à " & ' # ( à "#' " ' ' ! # %%%%%%%%%%%%%%%%%%%%%
Building a Visual Basic Application
| % )
' ' $ $ ' * # % $
Objects & Events
Structure of VB Program.
VB programs are made up of different subroutines (or procedures) of the form: s
VB Statements. Comments : Used to document programs and make them more readable. !)(+++ Terminate a program.
List of Procedures O
"& s
s
" ) ! " # " "$ " " % " # & "& ' ( " ") * " " " " " + #" , " "
s s !"#" s !"$ " s !"%" s !"&"
Arithmetic calculations
You can also perform simple arithmetic calculations VB uses * to denote the multiplication operator / to denote the division operator. The output is shown in figure, where the results are arranged vertically.
Print command ,
Example 2. can also be written as Private Sub Form_Activate ( ) Print 20 + 10, 20 ± 10, 20 * 10, 20 / 10 End Sub
The numbers will be arranged in a horizontal line separated by spaces as shown in figure.
Variables Example is an improved version of previous example as it employs two variables x and y and assigned initial values of 20 and 10 to them respectively. When you need to change the values of x and y, just change the initial values rather than changing every individual value which is more time consuming. " s '(!" )(" s '#) s '$ ) s '%) s '&)
Concatenation
" s (*+ * (,* -(* .(* ( / * s ##-#.#
use the î or the operator to two or more texts (string) together like in examples "
s (*+ * (,* -(* .(* ( / * s 00-0.0
à
Generally, there are three basic steps in building a VB application. The steps are as follows: Step 1 : Design the interface Step 2 : Set Properties of the controls (Objects) Step 3 : Write the events' procedures
! þ1 1 / 2 1 2-) / 2 / 1 34/ 1) 2 4 +'' ')/ 1) '5 ' ' 4/ / $ 2 1) )4 / 167 67 51 8) 1 2 )
&
# à
Working with Controls The Control Properties Before writing an event procedure for the control to response to a 's input, you have to set certain properties for the control to determine its appearance and how it will work with the event procedure. You can set the properties of the controls in the properties window
$ #' $ # #'
Working with Controls
Working with Controls Change its foreground and background color, change the font type and font size, enable or disable minimize and maximize buttons and etc. For example the following code will change the form color to red every time the form is loaded. VB uses hexadecimal system to represent the color. You can check the color codes in the properties windows which are showed up under ForeColor and BackColor . Private Sub Form_Load() Form1.Show Form1.BackColor = &000000FF& End Sub
Color ² returns or sets the background color of an object.
# ² returns or sets the foreground color used to display text and graphics in an object. Visual Basic uses the Microsoft Windows operating environment red-green-blue (RGB) color scheme.