CP1-unit3-MariaPistiolis

STUDY
PLAY
Starting Visual Studio
First Time Only:
Choose Default Environment Settings Dialogue Box

Pick the language you are using for the class.

Click on Start Visual Studio.

Microsoft Visual Studio will Load User Settings - Be Patient.

The IDE (Integrated Development Environment) screen will pop up where you create your projects objects and code.
Creating a New Project
The New Project dialog box is displayed.

Choose your programming language

Choose the template

VB: Windows Application

Change the Name

Change the Location

to where you are
saving your work.
Click OK
Visual Basic Project Folder
Contains the name of your current project and the many individual components which may be related to
the project.

includes a project file (.vbproj) and a solution file (.sln).

A project file contains information specific to a single programming task.

A solution file contains information about one or more projects.
Solution Explorer Window
If Your Visual Basic Project Only Contains One Project (.vbproj) and One Solution (.sln), Opening the Project is the Same as Opening the Solution .

For a Multi-Project Solution, Open the Solution File Only.
Visual Studio Tools
1. Designer Window
2. Solution Explorer Window
3. Properties Window, and
4. The Toolbox
Solution Explorer window
displays a list of the projects in the solution and the items contained in the project.
Designer Window
-Contains a Form.
-To Change the size of the Form
-Click and Drag the Sizing Handles on the Corner of the Form or
-Change the Size Properties (Measured in Pixels) on the Properties Window.
The Editor Window
This White Window Will Contain Your Program Code.
Properties Window
is Utilized to Change the Characteristics of Your Form During Design Time.
examples: Name
Font
AutoSize
BackColor
ForeColor
Enabled
Size
Text
Toolbox
Contains the Controls for Designing a Form.
Toolbox Controls
Controls Are Objects Which Can Be
Placed on Your Form Using Either
the Double-Click or Click and Drag
Method.
examples: Buttons
Labels
Option Buttons
Check Boxes
List Boxes, etc.
Common Controls: Button
clicked by the user to perform an action or group of actions.
Common Controls: TextBox
used to gather input from a user or to display text back to the user.
Common Controls: Label
used to display information to the user either to identify another object, provide instructions, or display output.
Common Controls: ListBox
used to display a list of items for a user to select. Multiple items can be selected.
Common Controls: ComboBox
A drop down menu that also allows a user to type in an entry or select an option.
Combines a ListBox and a TextBox
Common Controls: CheckBox
Usually found in a group box
Allows users to provide multiple inputs to answer a question
Common Controls: RadioButton
Used with group boxes
Allows user to make only one choice from the options in the group.
Common Controls: PictureBox
used to display a picture or image to the user.
Adding a Control
Click a control in the Toolbox and then click the form
The pointer shape displays an icon similar to the selected control.
There are snap-to lines that you can use for alignment.
Moving an object
Drag a control object to move it.
You can select a group to move together
Designing a Form
Remember that a balanced and pleasing design to a form is important.

Try to make your form appear as professional as possible.

When applying background color to your form, consider the user and/or culture.
Form Control
Every application will have at least one form which is automatically included.
form
is a graphical object that contains a title bar, a system menu and minimize, maximize and close buttons.
selected object
displays handles that appear as squares.
properties
of the Form object define its appearance, behavior, position and other attributes.

To set a property value
-Type or select a new value in the Properties window.
Form Control Properties
-Name
-Text is displayed in the title bar on top.
-BackColor changes the color of the form background
Set the properties
in the Properties window or during runtime.
The Label Control
The label allows you to display information or prompt the user.
Label Control Properties
(Name) should begin with lbl (lblPrompt).
Text is the text displayed in the label.
Font defines the font name, style, and size of the label text.
Autosize sizes the label to fit its text. Can be set to False so that the label size does not change.
TextAlign sets the alignment of the text within the label.
Set the properties
in the Properties window.
Using the Label Control VB
You wills use the label to display a message, information or a prompt.

Syntax for a label

lblName.Text = "message/info/prompt here"
Button control properties
(Name) should begin with btn (btnComplete)
Text - text displayed on the button
Using the Button Control
A Click event is usually coded for a Button object.

The object.method (btnCalc.click) after the "Handles" is the connection to the form.
This code will run when btnCalc is clicked during runtime.
The same object.method(btnCalc.click) after the "Sub" does NOT matter and can be changed without affecting when this code runs.
To Create a Button Click
Double click the button - or -
Open the code editor window.
-Select the button from the class name list
-Select the Click from the method name list
The CheckBox Control
Allows user to select options.

Can select more than one option.

Properties
Name - identifies the control - prefix is chk
Text - text displayed next to the box
Checked - True or False (will change to True when clicked and checkmark shows, changes to False when clicked and checkmark is removed). Can be set in properties window and also at runtime.

Can be placed in a GroupBox (add GroupBox before adding Checkboxes)
Placing in a GroupBox ties the CheckBoxes together.
The GroupBox Control
The GroupBox is in the Containers area of the Toolbox.

Properties
(Name) should begin with grp (grpCookies)
Text - text displayed at the top of the box
Checked Property
A checkmark shows when the Chili.Checked property is set to TRUE.
Using the CheckBox Control
You can use a CheckBox in several ways.
Click Event

Checked Property
We will use this in the decision unit(4.00) later to determine which checkbox was chosen.

You can create a CheckBox Click event the same way you created the Button Click.
To create a CheckChanged event, you will need to select the method from the code editor window.
The RadioButton Control
A group of radio control buttons is often used in an application to enable the user to choose from a set of options.

Only one radio button can be selected at any time.

RadioButton control properties

(Name) Should begin with rad (radChocChip)
Text the text displayed next to the button
Checked set to either True or False to display the radio button as selected or not selected.
Using The RadioButton Control
You can use a RadioButton in several ways.
Click Event



CheckChanged Event


Checked Property
We will learn more about this property later

You can create a RadioButton Click event the same way you created the Button Click.
To create a CheckChanged event, you will need to select the method from the code editor window.
YOU MIGHT ALSO LIKE...