Lec1 Visual Programming

download Lec1 Visual Programming

of 21

Transcript of Lec1 Visual Programming

  • 7/30/2019 Lec1 Visual Programming

    1/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.1

    Outlines of lecture 1

    1.1 What is Visual Basic?

    1.2 Significant Language features

    1.3 Important terminologies

    1.4 Graphic User Interface (GUI)

    1.5 Creating the project 1.6 Visual Basic Resources

  • 7/30/2019 Lec1 Visual Programming

    2/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.2

    1.1 What is Visual Basic?

    Programmers have undergone a major change in many years

    of programming various machines. For example what could be

    created in minutes with Visual Basic could take days in other

    languages such: as "C" or "Pascal". Visual Basic provides

    many interesting sets of tools to aid you in building exciting

    applications. Visual Basic provides these tools to make yourlife far more easier because all the real hard code is already

    written for you.

  • 7/30/2019 Lec1 Visual Programming

    3/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.3

    With controls like these you can create many applications which

    use certain parts of windows.

    For example, one of the controls could be a button. First createthe control on the screen, then write the code which would be

    executed once the control button is pressed. With this sort ofoperation in mind, simple programs would take very littlecode. Why do it like the poor old "C" programmer who wouldhave to write code to even display a window on the screen,when Visual Basic already has this part written for you.

  • 7/30/2019 Lec1 Visual Programming

    4/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.4

    Even though people tend to say Visual Basic's compiler is far

    behind the compilers of Pascal and C, it has earned itself the

    status of a professional programming language, and has almost

    freed BASIC of the reputation of a children's language.

    Overall you would class Visual Basic as a Graphics User

    Interface(GUI). Because as you draw, you write for theprogram. This must always be remembered in any kind of

    creation of a Visual Basic program.

    All in all, VB is the preferred language of many future program

    means. If you want to start programming Windows, and don'tknow how to start, give Visual Basic a shot.

  • 7/30/2019 Lec1 Visual Programming

    5/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.5

    1.2 Significant Language features

    Visual Basic is not only a programming language, but also a

    complete graphical development environment. Thisenvironment allows users with little programming experienceto quickly develop useful Microsoft Windows applicationswhich have the ability to use OLE ( Object Linking andEmbedding ) objects, such as an Excel spreadsheet.

    Visual Basic also has the ability to develop programs that can beused as a front end application to a database system, serving asthe user interface which collects user input and displaysformatted output in a more appealing and useful form than

    many SQL versions are capable of.

  • 7/30/2019 Lec1 Visual Programming

    6/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.6

    Visual Basic's main selling point is the ease with which it allows

    the user to create nice looking, graphical programs with littlecoding by the programmer, unlike many other languages thatmay take hundreds of lines of programmer keyed code.

    As the programmer works in the graphical environment, much ofthe program code is automatically generated by the VisualBasic program. In order to understand how this happens it isnecessary to understand the major concepts, objects and toolsused by Visual Basic.

  • 7/30/2019 Lec1 Visual Programming

    7/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.7

    The term "Personal Programming" refers to the idea that, wherever

    you work, whatever you do, you can expand your computer'susefulness by writing applications to use in your own job. PersonalProgramming is what Visual Basic is all about.

    Using Visual Basic's tools, you quickly translate an abstract idea

    into a program design you can actually see on the screen. VBencourages you to experiment, revise, correct, and network yourdesign until the new project meets your requirements. However ,most of all, it inspires your imagination and creativity.

  • 7/30/2019 Lec1 Visual Programming

    8/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.8

    Visual Basic can and is used in a number of different areas, forexample:

    Education

    Research

    Medicine Business

    Commerce

    Marketing and Sales

    Accounting Consulting

    Law

    Science

  • 7/30/2019 Lec1 Visual Programming

    9/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.9

    1.3 Important terminologies

    Properties -- attributes of objects

    Controls -- check boxes, list boxes, etc.

    Forms -- windows that contain applications controls

    Events -- messages or requests for service

    Procedures -- operations or services include methods, functions, subroutines

  • 7/30/2019 Lec1 Visual Programming

    10/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.10

    1.4 Graphic User Interface (GUI)

    Graphic User Interface (GUI) comprises

    Forms

    Controls

    Event-driven programming

  • 7/30/2019 Lec1 Visual Programming

    11/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.11

    The Windows GUI

    Text boxes

    Frame

    Labels

    Option buttons

    Check boxes

    Command buttons

    Image

    Picture box

  • 7/30/2019 Lec1 Visual Programming

    12/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.12

    Creating VB Applications

    Create the interface

    Set the properties

    Write the code

  • 7/30/2019 Lec1 Visual Programming

    13/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.13

    1.5 Creating the project

    On the file menu click new project.

    (or just click on create in the start page)

    New project window will appear, this window ask you to name

    your project. Type the project name then press ok button.

    New project dialog

  • 7/30/2019 Lec1 Visual Programming

    14/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.14

    Now on the screen you will see

    Form1.vb tab beside start tab

  • 7/30/2019 Lec1 Visual Programming

    15/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.15

    The Visual Basic development environment contains these

    programming tools and windows, witho which you construct your Visual Basic programs:

    o Menu bar

    o Toolbars

    o Visual Basic toolboxo Form window

    o Properties window

    o Solution Explorer

    o Immediate windowThe exact size and shape of the windows depends on how your

    system has been configured.

  • 7/30/2019 Lec1 Visual Programming

    16/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.16

  • 7/30/2019 Lec1 Visual Programming

    17/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.17

    1.6 Visual Basic Resources

    1. Programming Tools

    The location and purpose of the Visual Basic programming tools aredescribed in the following.

    Menu bar Located at the top of the screen, the menu bar providesaccess to the commands that control the Visual Basic programming

    environment. Menus and commands work according to standardconventions used in all Windows-based programs. You can usethese menus and commands by using keyboard commands or themouse.

    Toolbars Located below the menu bar, toolbars are collections of

    buttons that serve as shortcuts for executing commands andcontrolling the Visual Basic development environment. You canopen special-purpose toolbars by using the View menu Toolbarscommand.

  • 7/30/2019 Lec1 Visual Programming

    18/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.18

    Windows taskbar This taskbar is located along the bottom of the screen.

    You can use the taskbar to switch between Visual Basic forms as your

    program runs and to activate other Windows based programs.

    2. Properties Window

    With the Properties window, you change the characteristics (property

    settings) of the user interface elements on a form. A property setting is a

    characteristic of a user interface object. For example, you can change thetext displayed by a text box control to a different font, point size, or

    alignment. (With Visual Basic, you can display text in any font installed on

    your system, just as you can in Microsoft Excel or Microsoft Word.)

    Displaying the Properties Window

    To display the Properties window, click the Properties Window button on

    the toolbar. If the window is currently docked, you can enlarge it by

    double-clicking the title bar. To redock the Properties window, double-

    click its title bar again.

  • 7/30/2019 Lec1 Visual Programming

    19/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.19

    Changing Property Settings

    You can change property settings by using the Propertieswindow while you design the user interface or by using

    program code to make changes while the program runs.

    3. Solution Explorer (Project Window) A Visual Basic program consists of several files that are linked

    together to make the program run.

    The Visual Basic development environment includes a Project

    window to help you switch back and forth between thesecomponents as you work on a project.

  • 7/30/2019 Lec1 Visual Programming

    20/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.20

    4. Toolbox Controls

    You use special tools, called controls, to add elements of a program

    user interface to a form. You can find these resources in the toolbox,

    which is typically located along the left side of the screen. (If the

    toolbox is not open, display it by using the Toolbox command on

    the View menu.) By using toolbox controls, you can add theseelements to the user interface

  • 7/30/2019 Lec1 Visual Programming

    21/21

    Visual Programming,Lecturer Zaynab Al Quraishy, M.Sc.21

    5. Visible and Invisible Controls

    When a Visual Basic program runs, most toolbox controls

    operate like the standard objects in any Windows -based

    applicationand they will be visible to the user. However, the

    toolbox also contains controls that can be used to perform special,

    behind-the-scenes operations in a Visual Basic program. The

    powerful objects you create with these controls do useful workbut can be made invisible to the user when the program runs.

    These objects can be used for:

    Manipulating database information.

    Working with Windows-based applications.

    tracking the passage of time in your programs.