The Control Properties

Similar documents
Control Properties. Example: Program to change background color

SYLLABUS B.Com (Computer) VI SEM Subject Visual Basic Unit I

Programming with visual Basic:

Visual Basic 6 Lecture 7. The List Box:

2Practicals Visual Basic 6.0

Visual Basic Tutorial (Lesson 2)

NATIONAL DIPLOMA IN COMPUTER TECHNOLOGY

Lab Manual Visual Basic 6.0

An InputBox( ) function will display an input Box window where the user can enter a value or a text. The format is

Computer Science 110. NOTES: module 8

Visual Programming 1. What is Visual Basic? 2. What are different Editions available in VB? 3. List the various features of VB

Visual C# Program: Simple Game 3

Part 1: Basics. Page Sorter:

POS Designer Utility

Lecture Using ListBox and ComboBox Controls In Visual Basic 6: list box

After completing each task, be sure to save the file in the My Documents folder on your computer using the suggested name.

TSM Report Designer. Even Microsoft Excel s Data Import add-in can be used to extract TSM information into an Excel spread sheet for reporting.

Create a new document: Save your document regularly! The Big Picture: File>New

CENTAUR S REAL-TIME GRAPHIC INTERFACE V4.0 OPERATOR S MANUAL

Lesson 3 Creating and Using Graphics

Philadelphia University Faculty of Information Technology. Visual Programming

Function: function procedures and sub procedures share the same characteristics, with

A Complete Tutorial for Beginners LIEW VOON KIONG

COMP : Practical 6 Buttons and First Script Instructions

Microsoft Office 2010: Advanced Q&As Access Chapter 8

Visual Basic. The Integrated Development Environment. Menu Bar

v Annotation Tools GMS 10.4 Tutorial Use scale bars, North arrows, floating images, text boxes, lines, arrows, circles/ovals, and rectangles.

Detailed Table of Contents

Tech-Talk Using the PATROL Agent COM Server August 1999 Authored By: Eric Anderson

Type Storage Range of Values

Contents Introduction Getting Started Visual Basic Form Configuration Entering the VB Code

Paint/Draw Tools. Foreground color. Free-form select. Select. Eraser/Color Eraser. Fill Color. Color Picker. Magnify. Pencil. Brush.

Document Editor Basics

Lesson 4 Customize the ToolBox

Inspire Ten Minute Task #1

Table of Contents. iii

Full file at

Full file at Programming in Visual Basic 2010

Learning to use the drawing tools

Introduction to Flash - Creating a Motion Tween

Start Visual Basic. Session 1. The User Interface Form (I/II) The Visual Basic Programming Environment. The Tool Box (I/II)

Creating a Website with Publisher 2016

SETTINGS AND WORKSPACE

Interactive Tourist Map

Relational Operators. > greater than < less than >= greater than or equal to <= less than or equal to <> not equal to = equal to

A Step-by-step guide to creating a Professional PowerPoint Presentation

Simply Personnel Screen Designer

CS130/230 Lecture 12 Advanced Forms and Visual Basic for Applications

IGCSE ICT Section 16 Presentation Authoring

1 Using the NetBeans IDE

What s Inside. 1 Introducing Creating Visually Compelling Lectue Slides Access to Slide Creation Software Step- by- Step Examples...

Overview Guide NEW. Improved Toolbar. Lockable Objects. Transparent Objects. Improved Gallery. Multimedia Support.

Unit 21 - Creating a Navigation Bar in Macromedia Fireworks

LabVIEW Case and Loop Structures ABE 4423/6423 Dr. Filip To Ag and Bio Engineering, Mississippi State University

1. What is the definition of a problem? 2. How to solve problems? 3. What is meant by Algorithm? 4. What is a Program testing? 5. What is Flowchart?

Programming in C# Project 1:

HBS Training - IT Solutions. PlanWeb. Intermediate

Program and Graphical User Interface Design

Unit 11.Introduction to Form and Report

Answer: C. 7. In window we can write code A. Immediate window B. Locals window C. Code editor window D. None of these. Answer: C

FIT 100. Lab 8: Writing and Running Your First Visual Basic Program Spring 2002

HBS Training - IT Solutions. PlanWeb. Introduction

PROGRAM 1: SIMPLE CALCULATOR

How to Use Serif WebPlus 10

Making Your Showcase Portfolio

Corel Draw 11. What is Vector Graphics?

Using the new enhancements in forms designer:

LESSON 4 PAGE LAYOUT STRUCTURE 4.0 OBJECTIVES 4.1 INTRODUCTION 4.2 PAGE LAYOUT 4.3 LABEL SETUP 4.4 SETTING PAGE BACKGROUND 4.

Creating Icons for Leopard Buttons

Kidspiration 3 Basics Website:

Disclaimer. Trademarks. Liability

Using Visual Basic Studio 2008

2 USING VB.NET TO CREATE A FIRST SOLUTION

Teach Yourself Microsoft PowerPoint Topic 4: Slide Master, Comments and Save Options

2. If a window pops up that asks if you want to customize your color settings, click No.

ACTIVINSPIRE USER GUIDE TO HELP STAFF TRANSITION FROM ACTIVSTUDIO SUMMER 2010 MONTGOMERY COUNTY PUBLIC SCHOOLS TECHNOLOGY CONSULTING TEAM

Word Tutorial 4 Enhancing Page Layout and Design

Microsoft PowerPoint 2010

Recommended GUI Design Standards

Paint Tutorial (Project #14a)

ECDL Module 6 REFERENCE MANUAL

WINDOWS NT BASICS

CST242 Windows Forms with C# Page 1

New Perspectives on Microsoft Word Module 4: Enhancing Page Layout and Design

DESIGNING WEBSITES WITH iweb

This guide will show you how to create a basic multi-media PowerPoint presentation containing text, graphics, charts, and audio/video elements.

What is Publisher, anyway?

Click the buttons in the interactive below to learn how to navigate the Access window.

The American University in Cairo. Academic Computing Services. Word prepared by. Soumaia Ahmed Al Ayyat

November Copyright 2016 Open Systems Holdings Corp. All rights reserved.

A Frontpage Tutorial. Contents Page

animation, and what interface elements the Flash editor contains to help you create and control your animation.

Dive Into Visual C# 2008 Express

Designer Reference 1

LESSON B. The Toolbox Window

Access Forms Masterclass 5 Create Dynamic Titles for Your Forms

Read More: Index Function Excel [Examples, Make Dynamic Range, INDEX MATCH]

Angel International School - Manipay 1 st Term Examination November, 2015

A Guided Tour of Doc-To-Help

CPM-200 User Guide For Lighthouse for MAX

Transcription:

The Control Properties Figure Before writing an event procedure for the control to response to a user's input, you have to set certain properties for the control to determine its appearance and how it will work with the event procedure. You can set the properties of the controls in the properties window or at runtime. Figure on the right is a typical properties window for a form. You can rename the form caption to any name that you like best. In the properties window, the item appears at the top part is the object currently selected (in Figure, the object selected is Form1). At the bottom part, the items listed in the left column represent the names of various properties associated with the selected object while the items listed in the right column represent the states of the properties. Properties can be set by highlighting the items in the right column then change them by typing or selecting the options available. For example, in order to change the caption, just highlight Form1 under the name Caption and change it to other names. You may also try to alter the appearance of the form by setting it to 3D or flat. Other things you can do are to change its foreground and background color, change the font type and font size, enable or disable minimize and maximize buttons and etc. You can also change the properties at runtime to give special effects such as change of color, shape, animation effect and so on. For example the following code will change the form color to red every time the form is loaded and also displays the message welcome to visual basic form on the form. Double click on the form: Private Sub Form_Load() Form1.Show Form1.BackColor = vbred Form1.print welcome to visual basic form Another example is to change the control Shape to a particular shape at runtime by writing the following code. This code will change the 1

shape to a circle at runtime Private Sub Form_Load() Shape1.Shape = 3 few important points about setting up the properties. You should set the Caption Property of a control clearly so that a user knows what to do with that command. For example, in the calculator program, all the captions of the command buttons such as +, -, MC, MR are commonly found in an ordinary calculator, a user should have no problem in manipulating the buttons. use a meaningful name for the controls using the Name Property. This will be easier for the other users to write and read the event procedure and to debug or modify the programs later. However, it is not a must to do that as long as you label your objects clearly and use comments in the program whenever you feel necessary. One more important property is whether the control is enabled or not. Finally, you must also considering making the control visible or invisible at runtime, or when should it become visible or invisible. Some of the common controls The Form The Form is the first object you see when you Open the application. It is the window into which all the controls will appear, where you will input data and see results. 2

Caption of the form is changed to lesson4 Test Form using caption property and the Background colour to blue using Backcolor property. The Text Box The TextBox is like a Label but, it is used to input data into the program. The data typed in is in the Text property of the control. The text box is the standard control for accepting input from the user as well as to display the output. It can handle string (text) and numeric data but not images or pictures. String in a text box can be converted to a numeric data by using the function Val(text). The following example illustrates a simple program that processes the input from the user. Example 3.1 In this program, three text boxes are inserted into the form.two text boxes are used to accept inputs from the user and one to display the sum of two numbers that are entered into the two text boxes. Besides, a command button is also programmed to calculate the sum of the two numbers using the plus operator. Private Sub Command1_Click() To add the values in text box 1 and text box 2 Text3.text= Val(Text1.Text) + Val(Text2.Text) The Label The label is a very useful control for Visual Basic, as it is not only used to provide instructions and guides to the users, it can also be used to display outputs. One of its most 3

important properties is Caption. Using the syntax label.caption, it can display text and numeric data. You can change its caption in the properties window and also at runtime. The important properties to remember: Caption - the text that is displayed in the label BackColor and ForeColor - colors of the background and the text BackStyle - Opaque or Transparent - whether the background is visible or not Font - font and size of text Alignment - text centered, left or right Multiline- True or False - if True, you can have several lines of text The Command Button The command button is one of the most important controls as it is used to execute commands. It displays an illusion that the button is pressed when the user click on it. The most common event associated with the command button is the Click event, and the syntax for the procedure is Private Sub Command1_Click () Statements The Picture Box The Picture Box is one of the controls that is used to handle graphics. You can load a picture at design phase by clicking on the picture item in the properties window and select the picture from the selected folder. You can also load the picture at runtime using the LoadPicture method. For example, the statement will load the picture grape.gif into the picture box. Picture1.Picture=LoadPicture ("C:\VB program\images\grape.gif") The image in the picture box is not resizable. 4

The Picture property determines the name of the file,.bmp or.gif, that will be displayed. It can be used for a company logo, etc. The Image Box The Image Box is another control that handles images and pictures. It functions almost identically to the picture box. However, there is one major difference, the image in an Image Box is stretchable, which means it can be resized. This feature is not available in the Picture Box. Similar to the Picture Box, it can also use the LoadPicture method to load the picture. For example, the statement loads the picture grape.gif into the image box. Image1.Picture=LoadPicture ("C:\VB program\images\grape.gif") The List Box The function of the List Box is to present a list of items where the user can click and select the items from the list. In order to add items to the list, we can use the AddItem method. For example, if you wish to add a number of items to list box 1, you can key in the following statements Example 3.2 Private Sub Form_Load ( ) List1.AddItem Lesson1 List1.AddItem Lesson2 List1.AddItem Lesson3 List1.AddItem Lesson4 5

The items in the list box can be identified by the ListIndex property, the value of the ListIndex for the first item is 0, the second item has a ListIndex 1, and the second item has a ListIndex 2 and so on The Combo Box The function of the Combo Box is also to present a list of items where the user can click and select the items from the list. However, the user needs to click on the small arrowhead on the right of the combo box to see the items which are presented in a drop-down list. In order to add items to the list, you can also use the AddItem method. For example, if you wish to add a number of items to Combo box 1, you can key in the following statements Example 3.3 Private Sub Form_Load ( ) Combo1.AddItem Item1 Combo1.AddItem Item2 Combo1.AddItem Item3 Combo1.AddItem Item4 Frame When you want to group several controls together - name and address, for example - you use a Frame. The frame backcolor can be the same as the form's and only the frame borders will be obvious, or it can be a different color and stand out. You create the frame before the controls. When you create controls in a frame, they are tied to the frame and move with it. The frame caption is the text that appears at the top of the frame - you use it to define the group. The Check Box The Check Box control lets the user selects or unselects an option. When the Check Box is checked, its value is set to 1 and when it is unchecked, the value is set to 0. You can include the statements Check1.Value=1 to mark the Check Box and Check1.Value=0 to unmark the Check Box, as well as use them to initiate certain actions. For example, the program will change the background color of the form to red when the check box is unchecked and it will change to blue when the check box is checked. 6

Example 3.4 Private Sub Command1_Click() If Check1.Value = 1 And Check2.Value = 0 Then MsgBox "Apple is selected" ElseIf Check2.Value = 1 And Check1.Value = 0 Then MsgBox "Orange is selected" Else MsgBox "All are selected" End If The Option Box The Option Box control also lets the user selects one of the choices. However, two or more Option Boxes must work together because as one of the Option Boxes is selected, the other Option Boxes will be unselected. In fact, only one Option Box can be selected at one time. When an option box is selected, its value is set to True and when it is unselected; its value is set to False. In the following example, the shape control is placed in the form together with six Option Boxes. When the user clicks on different option boxes, different shapes will appear. The values of the shape control are 0, 1, and 2,3,4,5 which will make it appear as a rectangle, a square, an oval shape, a rounded rectangle and a rounded square respectively. Example 3.5 Private Sub Option1_Click ( ) Shape1.Shape = 0 Private Sub Option2_Click() Shape1.Shape = 1 Private Sub Option3_Click() Shape1.Shape = 2 Private Sub Option4_Click() 7

Shape1.Shape = 3 Private Sub Option5_Click() Shape1.Shape = 4 Private Sub Option6_Click() Shape1.Shape = 5 The difference between the option button and the check box is that with Check boxes one can select several at one time but, with Option buttons, he must select only one among several. The Drive List Box The Drive ListBox is for displaying a list of drives available in your computer. When you place this control into the form and run the program, you will be able to select different drives from your computer. 8

The Directory List Box The Directory List Box is for displaying the list of directories or folders in a selected drive. When you place this control into the form and run the program, you will be able to select different directories from a selected drive in your computer as shown in Figure 3.4 The File List Box The File List Box is for displaying the list of files in a selected directory or folder. When you place this control into the form and run the program, you will be able to shown the list of files in a selected directory as shown in Figure 3.5 You can coordinate the Drive List Box, the Directory List Box and the File List Box to search for the files you want. The procedure will be discussed in later lessons. 9