Basic GUI VISUAL BASIC. BASIC GUI Slide 2 of 53 Topic & Structure of the lesson Introduction Data Validation Use controls for making choices Write Pull.

Slides:



Advertisements
Similar presentations
Information System Design Lab 5&6. User Interface Design.
Advertisements

Benchmark Series Microsoft Access 2010 Level 1
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Chapter 1: An Introduction to Visual Basic 2012
Using Macros and Visual Basic for Applications (VBA) with Excel
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Chapter 1: An Introduction to Visual Basic.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Automating Tasks With Macros
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
C# Programming: From Problem Analysis to Program Design1 Programming Based on Events C# Programming: From Problem Analysis to Program Design 3 rd Edition.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
VB Default Controls List Box, Combo Box
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
CVEV 118/698 Visual Basic Lecture 3 Prof. Mounir Mabsout Elsa Sulukdjian Walid El Asmar.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Module 3 Productivity Programs Common Features and Commands Microsoft Office 2007.
COMPREHENSIVE Excel Tutorial 8 Developing an Excel Application.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Chapter 8: String Manipulation
© 2002 ComputerPREP, Inc. All rights reserved. Word 2000: Working with Long Documents.
Visual Basic Chapter 1 Mr. Wangler.
BIM313 – Advanced Programming Simple Controls 1. Contents Traditional Controls – Labels, Text Boxes, Buttons, Check Boxes, List Boxes, Combo Boxes Advanced.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Lab 9 – User Forms Design. User Forms What are user forms? –Known as dialog boxes –Major ways for getting user input An example of using user forms: Monthly.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Ch 11: Userforms CP212 Winter Topics Designing User Forms o Controls Setting Properties o Tab Order o Testing Writing Event Handlers o Userform_Initialize.
IE 411/511: Visual Programming for Industrial Applications
Chapter 2 More Controls Programming in C#. NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Appendices A - F A-F Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 4 I Need a Tour Guide.
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Copyright © 2001 by Wiley. All rights reserved. Chapter 2: Using Visual Basic to Create a First Project Getting Started with VB Development Environment.
ListBox, ComboBox, Menu Chapter 5.4, ComboBox Control: Properties & Methods u Combines TextBox features with a short drop- down list  cboOne.AddItem(string)
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 – Graphical User Interfaces Part 2 Outline.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Chapter Two Creating a First Project in Visual Basic.
Microsoft Access 2010 Chapter 10 Administering a Database System.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 10 1 Microsoft Office Access 2003 Tutorial 10 – Automating Tasks With Macros.
Integrated Development Environment Visual Basic IDE Slide 2 of 10 Topic & Structure of the lesson Introduction Integrated Development Environment Tool.
Slide 1 Using Menu Bar & Common Dialog Boxes. Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start.
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
Controls. Common properties Height – Height of the control Left – Left of the control Width – width of a control Top - From the screen top Font – Foreground.
Creating Menus Menu Bar – behaves like standard Windows menus Can be used in place of or in addition to buttons to execute a procedure Menu items are controls.
Chapter 2 More Controls Programming in C#. NET Objectives Use text boxes, group boxes, check boxes, radio buttons, and picture boxes effectively.
Chapter 3 I Need a Tour Guide (Introduction to Visual Basic 2010) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Chapter 5 Introduction To Form Builder. Lesson C Objectives  Use sequences to automatically generate primary key values in a form  Create lists of values.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
1 VB-06-String Manipulation Mar 03, 2002 String Function VISUAL BASIC.
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
1 Chapter 6: Creating Oracle Data Block Forms. 2 Forms  Application with a graphical user interface that looks like a paper form  Used to insert, update,
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
Chapter 1: An Introduction to Visual Basic .NET
Excel Tutorial 8 Developing an Excel Application
Chapter 1: An Introduction to Visual Basic 2015
Building a User Interface with Forms
Chapter 1: An Introduction to Visual Basic 2015
Visual Basic.
Windows xp PART 1 DR.WAFAA SHRIEF.
Creating Additional Input Items
Chapter 4 Enhancing the Graphical User Interface
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Chapter 4 Enhancing the Graphical User Interface
Presentation transcript:

Basic GUI VISUAL BASIC

BASIC GUI Slide 2 of 53 Topic & Structure of the lesson Introduction Data Validation Use controls for making choices Write Pull Down Menus

VISUAL BASIC BASIC GUI Slide 3 of 53 Learning Outcomes At the end of this lecture you will be able to : 1.Use MaskedEdit controls to format input data 2.Use Check Boxes for selecting several choices 3.Use ComboBox for selecting and displaying items

VISUAL BASIC BASIC GUI Slide 4 of 53 Key Terms you must be able to use If you have mastered this topic, you should be able to use the following terms correctly in your assignments and tests: Mask Edit – To validate user input Check Box – To select multiple options Combo Box – Displays items in a drop down manner

VISUAL BASIC BASIC GUI Slide 5 of 53 Mask Edit Control  Specialized version of a TextBox  MaskEdit allows for validation of input data  It ensures that only data in the correct format is accepted

VISUAL BASIC BASIC GUI Slide 6 of 53 Mask Edit Control Select Microsoft Masked Edit Control 6.0 from Project - Components Drag the Mask Edit Text Box from toolbar to the Form Right Click on the Mask Edit Control to set Properties for Mask Characters

VISUAL BASIC BASIC GUI Slide 7 of 53 Mask Characters #Numeric character. Decimal point,Thousand Separator /Date Separator :Time > Convert character to uppercase < Convert character to lowercase AAlphanumeric character ?Alpha character

VISUAL BASIC BASIC GUI Slide 8 of 53 Using Clip Text Clip text is used to remove all mask characters Private sub cmdsshow_click() Msgbox “Birthdate is ” & mskbirthdate.text Msgbox “Birthdate clip text is ” & mskbirthdate.cliptext End sub

VISUAL BASIC BASIC GUI Slide 9 of 53 Clearing the Mask Edit Private Sub Command1_Click() MaskEdBox1.Mask = “ ” 'Clear the mask MaskEdBox1.Text = “ ” 'Clear the edit box MaskEdBox1.Mask = “(###)-###-###” ‘ Restore the mask End Sub

VISUAL BASIC BASIC GUI Slide 10 of 53 Controls for making choices 1. Check Box 2. Option Button 3. List Box 4. Combo Box

VISUAL BASIC BASIC GUI Slide 11 of 53 Check Box Control  Use to give the user a True / False option  Allows the user to select one / more options from a list of independent options  When a check box is selected, the box is checked and the box is filled with a check mark  When a check box is deselected, the box is unchecked and the check mark is disappeared from the box

VISUAL BASIC BASIC GUI Slide 12 of 53 Check Box Control Commonly used properties of Check Box : Alignment : to set the alignment of the caption Caption : to specify the text that appears besides the check box Enabled : to set to True / False Name : to assign a name to check box Value : indicates whether the check box is checked / unchecked / unavailable / dimmed

VISUAL BASIC BASIC GUI Slide 13 of 53 Check Box Example Private Sub Command1_Click() If chkbold.Value = 1 Then MsgBox “Bold Selected” End If End Sub

VISUAL BASIC BASIC GUI Slide 14 of 53 Group Exercise Write a program that allows a user to select any 3 movie titles. Each movie costs RM 10. A user can select more than one movie Use check boxes to allow user selection Your program should display the total cost on a textbox with the message “You have to pay RM 99.99”.

VISUAL BASIC BASIC GUI Slide 15 of 53 Combo Box Control  It enables the users to select either by typing a text into the Combo Box or by selecting an item from the list.  It combines the features of Text Box and List Box  An item to Combo Box can be added both at design time and at run time

VISUAL BASIC BASIC GUI Slide 16 of 53 Combo Box Control

VISUAL BASIC BASIC GUI Slide 17 of 53 Combo Box Control ‘Adding Data to a combo Box Private Sub cmdInput_Click() cboCombo.AddItem(txtInput.Text) txtInput.Text = "" End Sub ‘Displaying a text Private sub cbocombo_click() Msgbox cboCombo.text End Sub

VISUAL BASIC BASIC GUI Slide 18 of 53 Combo Box Control ‘Clear All Items Private sub cmdclear_click() cbocombo.clear End sub ‘Removing a Selected Item Private sub cmdremove_click() cbocombo.removeitem (cbocombo.listindex) End sub

VISUAL BASIC BASIC GUI Slide 19 of 53 Group Exercise Write a program to add the following items to a combo box : Plane Ship Road When the user selects an item, display the selected item to a MsgBox “You Have Selected” Remove an item from the combo box when the item is selected

VISUAL BASIC BASIC GUI Slide 20 of 53 VISUAL BASIC Basic Graphical User Interface

VISUAL BASIC BASIC GUI Slide 21 of 53 Learning Outcomes At the end of this lecture you will be able to : 1.Use ListBox for displaying and removing items 2.Select options using Radio/Option buttons 3.Use the SSTab Control 4.Validate Text Boxes 5.Write pull down menus using Menu Editor

VISUAL BASIC BASIC GUI Slide 22 of 53 Key Terms you must be able to use If you have mastered this topic, you should be able to use the following terms correctly in your assignments and tests: List Box – To display items vertically. Option Buttons – To select a choice such as male of female. Key Press – To validate user’s input from the keyboard. Menu Editor - To display pull down menus.

VISUAL BASIC BASIC GUI Slide 23 of 53 List Box Control  It allows the user to view a list of items  User can select one / more items  If the no. of items exceed the value that can be displayed, a scrollbar will automatically appear on this control  The scrollbar allows the user to view a list of items

VISUAL BASIC BASIC GUI Slide 24 of 53 List Box Control Commonly used properties of List Box Listcount : specifies the no. of items in the box Listindex : contains the index of the selected item in the box.

VISUAL BASIC BASIC GUI Slide 25 of 53 List Box Control Commonly used methods of List Box Control AddItem : It is used to add an item to List Box List1.AddItem “APIIT DH”, 0 List1.AddItem “APIIT KL”, 1

VISUAL BASIC BASIC GUI Slide 26 of 53 List Box Control Commonly used methods of List Box Control RemoveItem: It is used to remove an item from the List Box List1.RemoveItem, 1 Clear : It is used to remove all items from the List Box. List1.Clear

VISUAL BASIC BASIC GUI Slide 27 of 53 List Box Example Private Sub cmdAdd_Click() lstList.AddItem(txtInput.Text) ‘add item to a list box txtInput.Text = "" End Sub Private Sub cmdRemove_Click() If lstList.ListIndex <> -1 Then lstList.RemoveItem(lstList.ListIndex) ‘remove an item from the list End If End Sub Private Sub cmdClear_Click() lstList.Clear ' Remove all list items from the list box End Sub

VISUAL BASIC BASIC GUI Slide 28 of 53 Group Exercise Write a program to add the following car type to a list box : –Toyota –Honda –Mitsubishi –Volvo –Proton 1.Create a button to add the items to a list box 2.Create a button to remove an item from the list box 3.Create a button to clear all items in the list box

VISUAL BASIC BASIC GUI Slide 29 of 53 Option Buttons/Radio Buttons Control  Option Buttons are used to display options.  They are grouped in an option group from which only one Option Button can be selected by the user.  Option Buttons are grouped by drawing the Buttons inside a Frame control / Picture control.  All Option Button controls within the same container act as single group.  When a user selects an Option Button, the other Buttons in the same group are automatically unavailable.

VISUAL BASIC BASIC GUI Slide 30 of 53 Using Option Buttons Private Sub command1_click() If optcash.Value = True Then Label1.Caption = "Cash Payment" ElseIf optcredit.Value = True Then Label1.Caption = "Credit Payment" End If End Sub

VISUAL BASIC BASIC GUI Slide 31 of 53 Group Exercise Write a program to accept a customers name and a purchase amount using two Text Boxes. Use option buttons to select a mode of payment either Cash or Credit If the payment is by Credit a charge of 15% is added to the purchase amount Display the actual amount to be paid on a label Sam you have to pay $____

VISUAL BASIC BASIC GUI Slide 32 of 53 SSTab Control To have different sections on a form Treat data as one logical unit Save, Update, Retrieve all data in as a single logical unit SS Tab must be added to the toolbox

VISUAL BASIC BASIC GUI Slide 33 of 53 SSTab Control 1.Click Project menu, select Components 2.Check the box “Microsoft Tabbed Dialog Control 6.0” 3.Click the OK Button

VISUAL BASIC BASIC GUI Slide 34 of 53 TextBox Validation Private Sub Text1_KeyPress(KeyAscii As Integer) valid = “abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQR STUVWXYZ /" If InStr(valid, Chr(KeyAscii)) = 0 Then KeyAscii = 0 End If End Sub

VISUAL BASIC BASIC GUI Slide 35 of 53 TextBox Validation Program below validates a text box to accept alphabets and the ‘/’ symbol Private Sub Text1_KeyPress(KeyAscii As Integer) Select Case KeyAscii Case Is = vbKeySpace 'control key Case Is < vbKeySpace 'control key Case vbKeyA To vbKeyZ, 97 To 122 'uppercase and lowercase Case 47 ‘ / Symbol Case Else MsgBox "Alpabets key only,please" KeyAscii = 0 End Select End Sub

VISUAL BASIC BASIC GUI Slide 36 of 53 Group Exercise 1.Write a program that will accept alphabets in a text box. If the user enters integers or other characters display an error message using a MsgBox. 2.Write a program that accepts your age in a text box.

VISUAL BASIC BASIC GUI Slide 37 of 53 Menu Editor To create pull down menus File –Student Registration –Book Registration –Book Borrow –Logout Each Menu item must have a menu name Menu name is given a prefix - mnu –mnufile –mnustudent –mnubookregister Menu Items

VISUAL BASIC BASIC GUI Slide 38 of 53 Menu Editor

VISUAL BASIC BASIC GUI Slide 39 of 53

VISUAL BASIC BASIC GUI Slide 40 of 53 Multiple Document Interface (MDI)  Able to open many child forms on a single parent form  Each window inside an MDI is called a child window.  Application window is called the parent window  Set Child Form property - MDI Child True

VISUAL BASIC BASIC GUI Slide 41 of 53 Create MDI Form –Project Menu

VISUAL BASIC BASIC GUI Slide 42 of 53 MDI Form

VISUAL BASIC BASIC GUI Slide 43 of 53 MDI Example Private Sub mnuform1_Click() Form1.Show End Sub Private Sub mnuform2_Click() Form2.Show End Sub Private Sub mnuhorizontal_Click() MDIForm1.Arrange (1) End Sub Private Sub mnucascade_Click() MDIForm1.Arrange (0) End Sub

VISUAL BASIC BASIC GUI Slide 44 of 53 MDI arrange methods constants ConstantValue Description vbCascade0Cascades child window vbTileHorizontal1Tiles child window horizontally vbTileVertically2Tiles child window vertically vbArrangeIcons3Arranges minimized child window at the bottom of parent window

VISUAL BASIC BASIC GUI Slide 45 of 53 Unloading a Form Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Dim r As Integer r = MsgBox("Are you sure you want to exit", vbYesNo) If r = vbNo Then Cancel = True End If End Sub

VISUAL BASIC BASIC GUI Slide 46 of 53 Timer Control Used to trigger an event at a scheduled time Timer control is located on the toolbar Timer event triggers at a set interval Interval is set on the Properties Windows One second = 1000 interval

VISUAL BASIC BASIC GUI Slide 47 of 53 Using Timer to Display Real Time Clock Private Sub Timer1_Timer() Text1.Text = Time End Sub

VISUAL BASIC BASIC GUI Slide 48 of 53 Follow Up Assignment Write a program that displays the names of 10 states of your country in a Combo Box. When an item is selected from the Combo Box, remove it.

VISUAL BASIC BASIC GUI Slide 49 of 53 Follow Up Assignment When the users selects an item from the ComboBox, remove the item from the ComboBox and add it to the ListBox. Your program should check to ensure that the ComboBox contains at least one item. If it does not, print a message using MsgBox and terminate the program.

VISUAL BASIC BASIC GUI Slide 50 of 53 Summary of Main Teaching Points Validation Mask Edit Key Press Event Controls for Choices Check Box Radio Buttons Combo Box

VISUAL BASIC BASIC GUI Slide 51 of 53 Q & A Question and Answer Session