CVEV 118/698 Visual Basic Lecture 3 Prof. Mounir Mabsout Elsa Sulukdjian Walid El Asmar.

Slides:



Advertisements
Similar presentations
Working with Intrinsic Controls and ActiveX Controls
Advertisements

Information System Design Lab 5&6. User Interface Design.
Chapter 1: An Introduction to Visual Basic 2012
Using Macros and Visual Basic for Applications (VBA) with Excel
Tutorial 12: Enhancing Excel with Visual Basic for Applications
1 Visual Basic Programming II Lecture 3 MIS233 Instructor – Larry Langellier.
Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.
Chapter 6 Multiform Projects Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Automating Tasks With Macros
Lab4 ListBox Control Properties, Methods and Events.
CVEV 118/698 Visual Basic Lecture 1 Prof. Mounir Mabsout Expert 1: Elsa Sulukdjian Expert 2: Walid El Asmar.
CVEV 118/698 AutoCAD VBA Lecture 1 Prof. Mounir Mabsout
VB Default Controls List Box, Combo Box
Graphical User Interface (GUI) A GUI allows user to interact with a program visually. GUIs are built from GUI components. A GUI component is an object.
MENUS AND THE MENU EDITOR Elements of a Menu Menu bar Menu title Separator bar Menu items.
Using the Visual Basic Editor Visual Basic for Applications 1.
Copyright 2003 : Ismail M.Romi, PPU. All Rights Reserved 1 Lab5 ListBox Control Properties, Methods and Events.
CVEV 118/698 AutoCAD 2000 Lecture 1 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.
Chapter 2: The Visual Studio.NET Development Environment Visual Basic.NET Programming: From Problem Analysis to Program Design.
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)
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Ten String Manipulation and Menus.
Chapter 8: String Manipulation
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File 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.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Multiple Forms and Standard Modules
Using Arrays and File Handling
5-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures.
Chapter 1: An Introduction to Visual Basic 2005 Programming with Microsoft Visual Basic 2005, Third Edition.
Multiple Forms, Container Controls, AddHandler This presentation is based on the Forms and ContainerControls VB Projects 1.
1 1 Lab1 Ismail M. Romi – IT Dept, PPU, Visual Basic 2005 Programming Tour.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
1 Working with Menus and Dialog Boxes. 2 Objectives You will be able to Create and edit menus for Windows Forms applications. Write code to handle menu.
Copyright © 2001 by Wiley. All rights reserved. Chapter 2: Using Visual Basic to Create a First Project Getting Started with VB Development Environment.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
ListBox, ComboBox, Menu Chapter 5.4, ComboBox Control: Properties & Methods u Combines TextBox features with a short drop- down list  cboOne.AddItem(string)
Graphical User Interface Concepts - Part 2 Session 09 Mata kuliah: M0874 – Programming II Tahun: 2010.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Multiform Projects.
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.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
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.
1 Visual Basic Part I - A tool for customizing your program Principles of GIS
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.
6-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
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 3 I Need a Tour Guide (Introduction to Visual Basic 2010) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Unit 6 Repetition Processing Instructor: Brent Presley.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Creating New Forms Projects can appear more professional when using different windows for different types of information. Select Add Windows Form from.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
COMPUTER PROGRAMMING I Apply Procedures to Develop List Box and Combo Box Objects.
Apply Procedures to Develop Menus, List Box and Combo Box Objects
3.01 Apply Controls Associated With Visual Studio Form
3.01 Apply Controls Associated With Visual Studio Form
Using Procedures and Exception Handling
Apply Procedures to Develop Menus, List Box and Combo Box Objects
Standard Controls.
CVEV 118/698 AutoCAD 2000 Lecture 1 Prof. Mounir Mabsout Elsa Sulukdjian Walid El Asmar.
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Presentation transcript:

CVEV 118/698 Visual Basic Lecture 3 Prof. Mounir Mabsout Elsa Sulukdjian Walid El Asmar

VB allows your program to support multiple forms. VB allows your program to support multiple forms. To add a new form, go to the Project Menu and Select Add Form. To add a new form, go to the Project Menu and Select Add Form. Each new form will be added in Project Explorer Window. Each new form will be added in Project Explorer Window. VB Multiple Form Support

Project Properties From Project select ProjectName Properties; or right click on the top line of the Project Explorer. From Project select ProjectName Properties; or right click on the top line of the Project Explorer. Specify Type/Name/Startup Object, I.e. which of the project’s forms should appear first at startup. Specify Type/Name/Startup Object, I.e. which of the project’s forms should appear first at startup.

Loading Forms Some forms need not to be displayed. They can contain procedures needed to be done in the background without showing it to the user. Some forms need not to be displayed. They can contain procedures needed to be done in the background without showing it to the user. If a form contains data that need time to be loaded, you can load the form, then show it. The user would not feel that it took time to show the form. If a form contains data that need time to be loaded, you can load the form, then show it. The user would not feel that it took time to show the form. Load FormName Unload FormName Warning: when a Form is loaded, it takes up resources from the system, accordingly you must unload all forms that are not needed. Warning: when a Form is loaded, it takes up resources from the system, accordingly you must unload all forms that are not needed.

Showing Forms Show method is used to display a form. Show method is used to display a form. FormName.Show mode When several forms are shown, and you want the user to proceed with some information on a particular one before taking any other action, use the modality property. This option is specified through the mode argument of the Show command: When several forms are shown, and you want the user to proceed with some information on a particular one before taking any other action, use the modality property. This option is specified through the mode argument of the Show command: Example: frmFirst.Show 0 frmSecond.Show 1 – 0 (default): Modeless. – 1: Modal, the Form takes control of the application and won’t let it proceed unless the Form is closed.

Form States Not loaded: The form exists on a disk file and doesn’t take any resources. Not loaded: The form exists on a disk file and doesn’t take any resources. Loaded but not shown: The form is loaded into memory, and is ready to be displayed. Loaded but not shown: The form is loaded into memory, and is ready to be displayed. Loaded and shown: The form is shown and the user can interact with it. Several forms may be shown at the same time. Loaded and shown: The form is shown and the user can interact with it. Several forms may be shown at the same time. Note: when a form is unloaded and then reloaded, there is a re-initialization of properties and variables declared in it. I.e. variable values are lost. This is not the case if a form is just made invisible, and then visible again. Note: when a form is unloaded and then reloaded, there is a re-initialization of properties and variables declared in it. I.e. variable values are lost. This is not the case if a form is just made invisible, and then visible again.

Control Visibility Option Explicit Private Sub btnShowFirst_Click() FormFirst.Visible = True FormSecond.Visible = False End Sub Option Explicit Private Sub btnShowSecond_Click() FormSecond.Visible = True FormFirst.Visible = False End Sub

Controlling a Form from Within Another When a form is loaded but invisible, it can still be manipulated. Accessing any control of this form (such as a TextBox) is done in the following manner: When a form is loaded but invisible, it can still be manipulated. Accessing any control of this form (such as a TextBox) is done in the following manner:FormName.ControlName.Command ex: Form1.txtGreeting.Text = “Hello”

Menu Design Menus are an important feature of Windows. They usually contain a large number of commands and options specific to the application in use. Menus are an important feature of Windows. They usually contain a large number of commands and options specific to the application in use. Menus can be attached only to forms. Menus can be attached only to forms. In VB, they are designed with the Menu Editor from the tools menu: In VB, they are designed with the Menu Editor from the tools menu: Tools > Menu Editor

Menu Editor Caption: String that appears on the application menu bar. Name: Name to be used when coding. Options: Controls how the commands will appear in the applications. Contents: This window shows the commands available in this menu bar. Shortcut: Run the command when pressed, without entering the menu. e.g. Ctrl+C.

Options and Features of Menu Editor Index: used to make a menu item part of a control array. This is helpful in making dynamic changes in the menu at runtime. Index: used to make a menu item part of a control array. This is helpful in making dynamic changes in the menu at runtime. WindowList: used when you have MDI (Multiple Document Interface) windows. WindowList: used when you have MDI (Multiple Document Interface) windows. Checked, Enabled, Visible: same commands as for other regular controls. Checked, Enabled, Visible: same commands as for other regular controls.

Menu: Results Option: enabled and visible. Option: visible. Option: enabled, visible and checked.

VB Controls

ListBox & ComboBox ListBoxes and ComboBoxes are used when dealing with a series of items, whether for simple display or for selection. ListBoxes and ComboBoxes are used when dealing with a series of items, whether for simple display or for selection. ListBoxComboBox - List appended by the program only. - Usually relatively large sized on screen. - Data accessed directly or with scrollbars. - User can also implement the list. - Usually small sized controls. - Data accessed through dropdown list.

ListBox & ComboBox Example ListBox ComboBox

ListBox & ComboBox Basic Properties MultiSelect: Defines if the user can select multiple item at a time, and the method of selection used. MultiSelect: Defines if the user can select multiple item at a time, and the method of selection used. Sorted: The items in the list are automatically sorted by the program. Sorted: The items in the list are automatically sorted by the program. Style: Controls the appearance of the control. Style: Controls the appearance of the control.

ListBox & ComboBox Basic Methods Add Item: Adds item to the list. Add Item: Adds item to the list. List1.AddItem item, index item is the string to be added index is the column where the item should be added in the list (if “sorted” is selected, this argument is neglected) Ex: lstGreetings.AddItem “hello”, 0 Remove Item: Removes an item from the list Remove Item: Removes an item from the list lstGreetings.RemoveItem index index = order of the item to be removed Clear: Removes all items from the control. Clear: Removes all items from the control. lstGreetings.Clear

ListBox & ComboBox Manipulation ListCount: Number of items inside the list. ListCount: Number of items inside the list. List1.ListCount (Generally useful in loops) List(): Array holding the list items List(): Array holding the list items List1.List(0) = “Hi” ListIndex: Index of the selected item in the list. ListIndex: Index of the selected item in the list. If List1.ListIndex > 0 Then … Selected: Array similar to List() but with elements that have a True or False value (if selected or not). Selected: Array similar to List() but with elements that have a True or False value (if selected or not). If ( List1.Selected(counter) ) Then… SelCount: Number of selected item. SelCount: Number of selected item.

Common Dialogs A tedious but common task in nearly every application is to prompt the user for filenames, font names and sizes, colors, etc. A tedious but common task in nearly every application is to prompt the user for filenames, font names and sizes, colors, etc. All Windows applications use standard dialog boxes for common operations such as selecting a file name. These dialogs are built into the Windows operating system. All Windows applications use standard dialog boxes for common operations such as selecting a file name. These dialogs are built into the Windows operating system. Common dialogs such as: Open, Save As, Color, Font, Print, Help are provided. All what you need to do is to set the flags properties. Common dialogs such as: Open, Save As, Color, Font, Print, Help are provided. All what you need to do is to set the flags properties.

Common Dialogs (cont’d)

Probably you will have to add the common dialog boxes to your toolbox: go to Project  Components  Microsoft Common Dialog Control 6.0 (SP3) Probably you will have to add the common dialog boxes to your toolbox: go to Project  Components  Microsoft Common Dialog Control 6.0 (SP3) Create a Common Dialog Control on your form. Create a Common Dialog Control on your form. The display of a Common Dialog box is done as follows: The display of a Common Dialog box is done as follows:CommonDialogName.Show**** Ex: CommonDialog1.ShowColor

What’s Next Thursday’s lab session Thursday’s lab session XO game assignment XO game assignment AutoCAD VBA AutoCAD VBA