1 / 30

Introduction to Visual Basic Programming

Introduction to Visual Basic Programming. Lecture Outline. History What is Visual Basic First Look at the VB 6.0 Environment Some VB Terminology Our first VB Program. History. BASIC. BASIC (Beginner's All-purpose Symbolic Instruction Code)

seth
Télécharger la présentation

Introduction to Visual Basic Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Visual Basic Programming

  2. Lecture Outline • History • What is Visual Basic • First Look at the VB 6.0 Environment • Some VB Terminology • Our first VB Program

  3. History

  4. BASIC • BASIC (Beginner's All-purpose Symbolic Instruction Code) • Designed in 1964, by Kemeny and Kurtz at Dartmouth • Goal was to provide access for non-science students to computers. • Back then all use of computers required writing custom software • But only Computer Scientists/Mathematicians did this • Language became widespread on microcomputers in the late 1970s and home computers in the 1980s.

  5. A Simple BASIC Program

  6. MS DOS Command Line

  7. MS-DOS Shell

  8. Visual Programming (MS Windows 3.1)

  9. Visual Programming Today (MS Vista)

  10. What is Visual Basic?

  11. What is Visual Basic?Visual Basic (VB) is a Microsoft Windows programming language (SOFTWARE development language)Visual Basic is derived from the BASIC (Beginners All-purpose Symbolic Instruction Code) programming languageBASIC was developed in the mid-1960sThe widespread use of BASIC led to many enhancements to the languageIn the late 1980s and early 1990s, with the development of the Microsoft Windows (Graphic User Interface) GUI, the natural evolution of BASIC was Visual Basic (created by Microsoft in 1991)

  12. VB greatly simplifies the development of Microsoft Windows-based ApplicationsBetween 1991 and 1998 6 versions of VB were released, with Visual Basic 6 appearing in September 1998.Microsoft provides several versions of VB, namely the Learning Edition, the Professional Edition and the Enterprise EditionVB programs are created in an Integrated Development Environment (IDE). The IDE allows a programmer to create, run and debug VB programs conveniently.The process of rapidly creating an application is typically referred to as Rapid Application Development (RAD). VB is the most widely used RAD language.

  13. The Visual Basic Environment Visual Studio

  14. The Visual Basic EnvironmentIn using VB you will learn to write computer programs that run in the Microsoft Windows environmentProjects will look and act like standard Windows programsVB provides the tools you need to create windows with familiar elements like: Menus, Text Boxes, Command Buttons, Option Buttons, Check Boxes, List Boxes, and Scroll Bars

  15. Microsoft Windows uses a Graphic User Interface (GUI)The Windows GUI defines how the various elements look and functionWithin VB there is a Toolbox of these elementsIn VB you will create new Windows called FormsUsing the toolbox to add the various elements, called Controls, to the formVB programming is known as Event-Driven Programming

  16. The Initial Visual Basic Screen Menu bar Project Explorer window Toolbar Toolbox Properties window Description pane Form Project Container window Form Layout window

  17. Some VB Terminology Objects, Properties and Methods

  18. In VB you work with Objects, which have Properties and MethodsObjects: Think of an Object as a thing, or a nounExamples of Objects are Forms and ControlsForms are the Windows and Dialog Boxes that you place on the screenControls are the elements you place inside a form, such as Text Boxes,Command Buttons, and List Boxes

  19. Properties: Think of Properties as adjectives that describe objects Properties tell something about an Object, such as the name, colour, size, location, and how it will behaveWhen you refer to a Property[1] Name the Object [2] Name the Property(Example: Form1.Caption)The Caption Property of the Object (Form) called Form1

  20. Methods: Methods are the verbs of Object-Oriented ProgrammingMethods are Actions associated with ObjectsExample of Methods include Move, Print, Resize, and ClearRefer to Methods as:Object.Method(Example: Form1.Print)Sends output (Prints) to the Object (Form) called Form1(Question: What does this Method refer to?)Printer.Print

  21. Steps to Create a Visual Basic Program 1. Create the interface by placing controls on the form 2. Set properties for the controls and the form 3. Write code for event procedures associated with the controls and the form

  22. Placing a Text Box on a Form • Double-click on the text box icon in the toolbox to add a text box to your form • Activate the properties window (Press F4) • Set values of properties for text box

  23. Placing a Text Box on a Form Text box

  24. Our First VB Program “Hello World”

  25. Private Sub cmdPush_Click ‘Display the ‘Hello World’ Message lblMessage.Caption = “Hello World”End Sub***********************************************Private Sub cmdExit_Click ‘Exit the project EndEnd Sub Comment Assignment

  26. Naming Objects:

  27. Visual Basic Events • Code is a set of statements that instruct the computer to carry out a task. • Code can be associated with events • When an event occurs, the code associated with that event (called an Event Procedure) is executed.

  28. Creating An Event Procedure • Double-click on an object to open a Code window. (The empty default event procedure will appear. Click on the Procedure box if you want to display a different event procedure.) • Write the code for that event procedure.

  29. Example of An Event Procedure Private Sub objectName_event ( ) statements End Sub Private Sub txtOne_GotFocus( ) txtOne.Font.Size = 12 txtOne.Font.Bold = False End Sub

  30. More Examples Private Sub cmdButton_Click( ) txtBox.ForeColor = vbRed txtBox.Font.Size = 24 txtBox.Text = “Hello” End Sub

More Related