Presentation is loading. Please wait.

Presentation is loading. Please wait.

CHAPTER TWO INTRODUCTION TO VISUAL BASIC © Prepared By: Razif Razali 1.

Similar presentations


Presentation on theme: "CHAPTER TWO INTRODUCTION TO VISUAL BASIC © Prepared By: Razif Razali 1."— Presentation transcript:

1 CHAPTER TWO INTRODUCTION TO VISUAL BASIC © Prepared By: Razif Razali 1

2 INTRODUCTION Visual Basic is an extremely flexible programming product designed for a variety of applications. Students, managers, and people in various technical fields use Visual Basic to learn how to write practical, Windows-based programs; business professionals use Visual Basic to write macros that leverage the documents and capabilities of their Microsoft Office applications; and experienced software developers use Visual Basic to build powerful commercial applications and corporate productivity tools. © Prepared By: Razif Razali 2

3 OBJECTIVES In this chapter, you'll learn how to: Explore and configure the Visual Basic development environment. Build your first program. © Prepared By: Razif Razali 3

4 Why Visual Basic? The advantages of Visual Basic:  It's simple language.  Because Visual Basic is so popular, There are many good resources (Books, Web sites, News groups and more) that can help you learn the language.  You can find many tools (Sharewares and Freeware) on the internet that will Spare you some programming time.  Compare to other languages, Visual Basic have the widest variety of tools that you can download on the internet and use in your programs.

5 Why Visual Basic? The disadvantages of Visual Basic: Visual Basic is powerful language, but it's not suit for programming really sophisticated games. It's much more slower than other languages. © Prepared By: Razif Razali 5

6 VISUAL BASIC ENVIRONMENT The Visual Basic development environment contains these programming tools and windows, with which you construct your Visual Basic programs: Menu bar Toolbars Visual Basic toolbox Form window Properties window Project Explorer Immediate window Form Layout window © Prepared By: Razif Razali 6

7 Graphical User Interface Visual Basic allows you to create GUIs Graphic User Interface (GUI) comprises ◦ Forms ◦ Controls ◦ Event-driven programming Revolutionized the Computer Industry Allows input forms or boxes…much friendlier interface

8 Visual Basic GUI - Example Text boxes Frame Labels Option buttons Check boxes Command buttons Image Picture box

9 Graphic User Interface Controls: The responsive objects a programmer places on a window These objects recognize user actions such as mouse movements and button clicks A good analogy:For Example ◦ Objects (nouns)Option button ◦ Properties (adjectives)What it looks like ◦ Methods (verbs)What it does

10 Writing Visual Basic Projects The three-step process for planning projects ◦ Design the user interface  Sketch the screens with forms and controls needed ◦ Establish the objects' properties  Write down the properties for each object ◦ Plan the Basic code  Write out pseudo code for actions your program will perform

11 When the Program is Running Visual Basic monitors the controls in the window to detect any event (click, for example) When events detected, examine program to see if there’s a procedure associated with it If there is a procedure, execute it If there is no procedure, wait for the next event

12 The Visual Basic Environment Form, Project Explorer, Properties, and Form Layout Windows Toolbox Main Visual Basic window Toolbar, Form location & size information Help Design-, Run- …

13 VB Environment

14

15

16

17

18

19 Control A control is a tool you use to create objects on a Visual Basic form. You select controls from the toolbox and use the mouse to draw objects on a form. You use most controls to create user interface elements, such as command buttons, image boxes, and list boxes. © Prepared By: Razif Razali 19

20 Object An object is a type of user interface element you create on a Visual Basic form by using a toolbox control. You can move, resize, and customize objects by setting object properties. Objects also have what is known as inherent functionality — they know how to operate and can respond to certain situations on their own. A list box “knows” how to scroll, for example. You can customize Visual Basic objects by using event procedures that are fine-tuned for different conditions in a program © Prepared By: Razif Razali 20

21 Property A property is a value or characteristic held by a Visual Basic object, such as Caption or Fore Color. Properties can be set at design time by using the Properties window or at run time by using statements in the program code. In code, the format for setting a property is: Object. Property = Value Where ◦ Object is the name of the object you’re customizing. ◦ Property is the characteristic you want to change. ◦ Value is the new property setting. For example, Command1.Caption = "Hello" Could be used in the program code to set the Caption property of the Command1 object to “Hello”. © Prepared By: Razif Razali 21

22 Event Procedure An event procedure is a block of code that runs when a program object is manipulated. For example, clicking the first command button in a program executes the Command1_Click event procedure. Event procedures typically evaluate and set properties and use other program statements to perform the work of the program. © Prepared By: Razif Razali 22

23 Method A method is a special keyword that performs an action or a service for a particular program object. In code, the format for using a method is Object. Method Value Where ◦ Object is the name of the object you are working with. ◦ Method is the action you want the object to perform. ◦ Value is an optional argument to be used by the method. For example, this statement uses the Add Item method to put the word Check in the List1 list box: List1.AddItem "Check" © Prepared By: Razif Razali 23

24 NAMING VISUAL BASIC OBJECTS Programmers typically create names for their objects that clearly identify the purpose of the object and the toolbox control that created it. For example, you might give the name lblInstructions to a label that displays user- operating instructions. In this case, lbl stands for the Label control, and Instructions describes the label's purpose. © Prepared By: Razif Razali 24

25 OBJECT NAMING CONVENTIONS © Prepared By: Razif Razali 25

26 Version of Visual Basic Can be grouped into:- ◦ Learning Edition ◦ Professional Edition ◦ Enterprise Edition

27 Learning Edition Basic programming editor Helps educate all users on how to program in Visual Basic.

28 Professional Edition Includes new features such as Visual C++ 6.0 optimized native-code compiler, ADO (Active Data Object), Database Tools, Automatic Data Binding, Dynamic HTML, Mobile Computing, etc

29 Enterprise Edition Visual Basic 6.0 Enterprise Edition includes step by step instructions for how to take advantage of Windows 2000 features, native code compiler, ADO (Active X Data Objects), Integrated Enterprise tools to implement databases into applications, Automatic data binding, Dynamic HTML Page Designer, Mobile Computing Support, Microsoft SQL Server 6.5 Developer Edition, Visual Modeler, Microsoft Visual SourceSafe 6.0 and much more.

30 SUMMARY Graphical User Interface (GUI) Programming Languages: ◦ Procedural ◦ Object Oriented ◦ Event Driven Objects, Properties and Methods Version of Visual Basic The three step process © Prepared By: Razif Razali 30


Download ppt "CHAPTER TWO INTRODUCTION TO VISUAL BASIC © Prepared By: Razif Razali 1."

Similar presentations


Ads by Google