working with intrinsic controls and activex controls project 2
TRANSCRIPT
![Page 1: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/1.jpg)
Working with Intrinsic Controls and ActiveX Controls
Project 2
![Page 2: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/2.jpg)
Introduction
Intrinsic Controls – the basic set of twenty controls in the toolbox.Are a part of the .exe VB program.
ActiveX Controls – exists as separate files.Files have a .ocx extension.
![Page 3: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/3.jpg)
Introduction cont……….
Many routines and procedures are built into applications that are not designed for the end user.
![Page 4: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/4.jpg)
Creating the Interface
Consists of sizing and locating the GUI and then adding the controls necessary for the user to use the form.
![Page 5: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/5.jpg)
Form Size and Position
Height and Width property values can change the size of the form.
Top and Left property values change the position of the form.
![Page 6: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/6.jpg)
AutoSize and BackStyle Properties
AutoSize – when set to True, the size of the control (label) will depend on the size of the caption property.
BackStyle – when set to Transparent, the color of the control below the label displays within the label’s border.
![Page 7: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/7.jpg)
Copying Controls
You can copy and paste controls. A message will ask you if you want to
create a control array.Click “NO” if you just want a copy of the
control.We will work with control arrays later on.
![Page 8: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/8.jpg)
ListBox and ComboBox Controls
Used to present the end user with choices from a list.
When a list is longer than the list box, scroll bars automatically appear.
![Page 9: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/9.jpg)
ListBox and ComboBox
Control Appearance of List
Selection From List
ListBox List always shows, scroll bars added if list is longer than box.
Click item in list
ComboBox(Style = 0) Drop-down list Click item in list or type directly in box.
ComboBox(Style=1) List always shows, scroll bar added if list is longer than box.
Click item in list or type directly in box.
ComboBox(Style=2) Drop-down list Click item in list
![Page 10: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/10.jpg)
Shape Control
Used to add shapes to the formSquareCircleRectangle
![Page 11: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/11.jpg)
CheckBox Control
Used to turn controls on or off. Indicate the selection of deselection of
check boxes on a form.
![Page 12: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/12.jpg)
Frame Control
Used as a container for other controls, such as option buttons.A frame can only have a rectangle shape.A frame can have a caption.When option buttons are added to the frame,
only one can be selected at a time.
![Page 13: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/13.jpg)
Option Button Control
Presents a set of choices. Placed in groups, such as on a frame
control.Must be drawn directly on the frame to be a
part of the group.
![Page 14: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/14.jpg)
CommonDialog Control
Allows you to add the Open, Save As, Color, Print and Font commands.
Not visible during run time. Activate the CommonDialog control by
using one of the Show methods.
![Page 15: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/15.jpg)
Aligning Controls
Used to align controls in the form.VerticallyHorizontally
Format menu
![Page 16: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/16.jpg)
Naming Controls
The name of a control is a property of a control.
Helps the programmer know what control he/she is working with when writing code.
Table 2-2
![Page 17: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/17.jpg)
Writing Code
Project 2
![Page 18: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/18.jpg)
Changing Control Properties
Basic Formatcontrolname.property = value
![Page 19: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/19.jpg)
Variables
Temporary storage locations. Each variable has a
NameData Type – determines the type of data the
variable can hold.
![Page 20: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/20.jpg)
Variables cont………..
Must follow these rules when choosing names for variables.The name must begin with a letter.The name cannot be more than 255
characters.Then name cannot contain punctuation or
blank spaces.
![Page 21: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/21.jpg)
Declaring Variables
You must declare, or create, a variable.This will be done by Explicitly Declaring them.
Dim variablename As datatype
There can be a wide variety of different data typesByte, date, string, integer, variant, double
![Page 22: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/22.jpg)
Assigning values to a variable
Variables can hold one value at a time. We use assignment statements to give
variables a value.dblRate = 10.5strName = “Mr. Preheim”
![Page 23: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/23.jpg)
Variable Scope
Refers to whether or not the variable is visible to other sub routines.
Variables declared in a sub routine are not visible by other sub routines in the program.
Variables declared in the General Declarations are visible to all subroutines for that form.
![Page 24: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/24.jpg)
Arithmetic Expressions
Code that contains statements to perform mathematical operations.
Order of Precedence – the order in which the calculation will take place.Can change the order of precedence by using
parentheses. Refer to table 2-7
![Page 25: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/25.jpg)
Arithmetic Expression Examples
dblPayRate = dblHours * curWage dblTotal = intNumber1 + 100
![Page 26: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/26.jpg)
If..Then…Else Statements
Used to execute one statement or another based on whether a condition is True or False.
A condition is made up of a 2 expressions and a comparison operator.=, <, >, <=, >=, <>
![Page 27: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/27.jpg)
Key words in an If…Then…Else Statement If Then Else End If
![Page 28: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/28.jpg)
If Statement Structure
If condition Then Block of code if the condition is TrueElse Block of code if the condition is FalseEnd If
![Page 29: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/29.jpg)
If Structure Flowchart Example
Is Matinee Check Box
Checked
Price = 5 Price = 3.5
F T
![Page 30: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/30.jpg)
If Structure VB Code Example
If chkMatinne.Value = 1 Then Price = 3.5Else Price = 5End IF
![Page 31: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/31.jpg)
Constants
Similar to a variable in the idea that it uses space in memory.
However, the value of a constant does not change.
Defined by using the Const statement in the General Declarations.
![Page 32: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/32.jpg)
Concatenation
The process of adding strings together is called concatenation.
Performed by using the ampersand (&) character.
Example:textRecord.Text = num & “ ” & cboShow.Text & vbNewLine
& txtRecord.Text
![Page 33: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/33.jpg)
Items in a ComboBox
When items are added to a ComboBox, they are assigned an Index number.The first item is assigned an index of 0.
When an item is selected from the list during runtime, that index number is assigned to the ListIndex property.
![Page 34: Working with Intrinsic Controls and ActiveX Controls Project 2](https://reader034.vdocument.in/reader034/viewer/2022050703/551abd1555034656628b56fc/html5/thumbnails/34.jpg)
Writing Code for the Common Dialog Control To display the Color dialog box, you will
apply the ShowColor method.