Beruflich Dokumente
Kultur Dokumente
1
INTRODUCTION TO VISUAL BASIC PROGRAMMING
BY : RAZIF MUSTAPHA
Learning Objectives
2
techniques to illustrate the relationship between data or the changes to the data. Despite the fact that the visual communication in VPL is higher compared to the traditional textbased programming, text is still being used in visual programming.
F 3005 VISUAL BASIC PROGRAMMING
Example: Visual objects with the addition and subtraction functions that will receive 2 numbers as the input to generate one output.
Diagram 1.1
F 3005 VISUAL BASIC PROGRAMMING
from a DOS version; BASIC. Easy to learn and the code are English-like statements. The programming language is Visual based and is based on event.
Definition
VISUAL + BASIC
Visual
8
VISUAL Is a method to design graphical user interface. You dont need to write lines of codes to display the position of your objects just click and drag to place the object at a suitable position on the screen.
Basic
9
BASIC
Based on the BASIC (Beginners All-Purpose Symbolic Instruction
Code), a language that is commonly used by most programmers compared to other traditional programming languages (e.g. FORTRAN).
You did it!
CLS PRINT You did it! PRINT PRINT You are now a programmer.
Program output
VISUAL BASIC
10
contains hundreds of statement, functions and keywords. Visual Basic is also a method to create Graphic User Interface, (GUI).
VISUAL BASIC
11
VISUAL BASIC
12
applications with suitable GUIs quickly. Enable a quick application development or Rapid Application Development RAD software. Examples of programming languages with RAD feature: Borland Delphi, Borland C++ Builder, Microsoft J++, Microsoft Visual Basic, etc.
F 3005 VISUAL BASIC PROGRAMMING
VISUAL BASIC
13
Instruction Code).
Year 1960s Description John Kemeny and Thomas Kurtz at Dartmouth College developed BASIC (Beginners All-Purpose Symbolic Instruction Code). Many versions of BASIC were developed, including MS-BASIC and QuickBASIC (Qbasic). Microsoft Corporation has developed Visual Basic as a Windows application designed to assist programmers in developing other event-driven Windows applications. The 6th Version of Visual Basic was launched. Microsoft introduced Visual Basic .NET 1.0
Late 1980s
1991
Thomas Kurtz
John G. Kemeny
Professional Edition
Enterprise Edition
VISUAL BASIC
17
Active X Technology Allow integration with different applications. Example: Microsoft Word Processor, Microsoft Excel.
VISUAL BASIC
18
interface in order to help you in creating interface and code for an application easily.
It is built in the Windows environment and deals with
objects.
The concept covers - windows, events, messages,
read and based on the instructions from each line of code, it will trigger the necessary procedures.
In an event-driven application, codes do not go through a
fixed direction. Codes are activated based on an event, triggered by user action through messages from the system or another application or the local application.
F 3005 VISUAL BASIC PROGRAMMING
Visual Basic is an OOED language. OOED is easier to work with, because it is more intuitive
fixed direction. Codes are activated based on an event, triggered by user action through messages from the system or another application or the local application.
F 3005 VISUAL BASIC PROGRAMMING
OOED
21
Diagram 1.5: Example of an event, triggered when user clicks the command button, Done
F 3005 VISUAL BASIC PROGRAMMING
Message
22
the operating system. The system will process the message and display the output in a different window.
Each window can take necessary action based on its
own instruction to handle specific messages (example: changing the color of the window when closing another window).
Message
23
Objects
24
objects name will begin with three-lettered prefix that signifies the type of the object.
Objects
25
Programmers who are new to object technology should view OOP as an important, new computer-programming paradigm.
Decision about application design are made before programming (or
to-many lines of programming instructions based on well-defined design models. Such design models are graphical illustrations that represent different aspects of objects, those objects classes (from which they derive functions and property variables), and their interactions with each other.
Objects
26
Object
Action associated with object are called methods. Methods are the verbs of object-oriented
programming. Some typical methods are Move, Print, Resize, Clear etc. Properties tell something about an object, such as its name, color, size, font or how it will behave.
QBASIC
Visual Basic
DOS based
Window based
Requires long lines of codes to Programs are written with the involvement of mouse clicks, oncreate a program screen buttons and drag & drop tools.
QBASIC is a translator, eases testing Visual Basic requires a compiler but difficult to distribute and protect unless you have a separate compiler. QBASIC can never be developed for Large program size with visual bigger programs because it is only effects and GUI can be limited to 0.16MB of memory. It has developed. no visual displays.
F 3005 VISUAL BASIC PROGRAMMING
Private Sub Event for an object Variable declaration Any VB statements Note Event for an object End Sub oEvents can occur through user
actions such as a mouse click or a key press, through programmatic control, or even as a result of another window's actions, e.g. Command1_Click () Visual Basic program statement oComprise functions, methods, comments and procedures.
Break!
Setting properties
Phase 2
Writing code
Phase 3
VB Development Environment
33
SDI Independent Windows on the desktop. Suitable for windows with low resolution.
MDI Window within a window on the desktop. Suitable for windows with higher resolution.
You should start in the default MDI environment. Project Window should have a white background. Form Window is shown as part of a larger Project Window.
F 3005 VISUAL BASIC PROGRAMMING
VB Development Environment
35
twips.
1440
twips is 1 inch, when printed. 120 twips is the distance between dots on the grid
VB Development Environment
36 Toolbar
Project Window
VB Development Environment
37
1. Form a window in which the application is designed. 2. Toolbox for drawing controls on the form 3. Project Explorer a list of any forms and other types of files in the project 4. Properties Window a list of the property settings for a particular control
The menu bar has drop-down menus from which you control the operation of the Visual Basic environment. It has buttons that provide shortcuts to some of the menu options. It also shows the location of the current form relative to the upper left corner of the screen (measured in twips) and the width and length of the current form.