Computer Programming
Computer Programming
Programming Paradigm/Methods
Visual Basic.Net
-Visual Basic.net is an object-oriented/event-driven programming language used to develop local based-
and web based applications.
-Can be downloaded from www.microsoft.com/vb.
-To install Visual Basic, double-click the downloaded file then follow the on-screen prompt.
Standard Controls
Form
-Foundation of all windows application.
Properties:
1. Name- a name used to refer to a form control in the code.
*use .NET NAMING CONVENTION in naming your form.
*objectPurpose+ObjectType
displaytextForm
computeForm
addForm
2. Text-changes the text displayed in the form title bar.
*To add a descriptive form title, complete the sentence
“This form allows you to__________.”
*Form title should be title capitalized.
Label
-Displays read-only text.
Properties:
1. Name- a name used to refer to a label control in the code.
2. Text-changes the label text.
Label design guide:
• Must contain one to three words.
• Should appear in one line.
• Must be typed in sentence capitalization.
• Should end with a colon.
2. Buttons
-elicits simple response
Properties
1. Name
2. Text
Design Guide:
1. Must have same height and width
2. Must be in one row or column
3. Button text must be title capitalized.
TextBox
-Accepts an input from the user.
Properties:
1. Name- a name used to refer to a textbox control in the code.
2. Text-sets/gets the textbox text.
• Textbox design guide:
*The width of the textbox depends upon the expected number of characters that will be
entered to it.
Variables and Data Types
A variable is a memory location that stores changeable value.
Naming Variables
• Begins with a letter
• Does not include spaces and punctuations.
• Must be at least 255 characters.
• Do not use reserved words as variables.
Declaring Variables
-To declare a visual basic.net variable, use the following syntax:
accessibilityCommand variableName as Data Type
Example:
dim intNum as integer
public strName as string
Scope of a Variable
1. Local variable- a variable known by one procedures.
– To create a local variable, use the dim accessibility command.
2. Global variable- a variable known by all procedures.
– To create a global variable, use the public accessibility command.
Data Types
Data Types defines the type of data that the variable will handle.
Mathematical Operators
-Performs calculation and computations.
-Also called arithmetic operators.
Operator Stores
^ Exponentiation
*,/ Multiplication and
Division
\ Integer Division
Mod Modulus Division
+,- Addition and Subtraction
Example:
1. Make a program that will ask two numbers and display the sum of the inputted numbers.
2. Write a program that will ask your dog’s age in years and convert it to human years. To convert dog years to human years,
multiply the inputted dog years by 15.
Activity:
1. Make a program that will asks two numbers and display the sum, difference, product , and quotient.
2. Write a program that will ask your cat age in years and convert it to human years. To convert a cat years to human years,
multiply the inputted cat years by 7.
3. Write a program that will ask your age and display how many days you have been alive.
Conditional Structure
-integrates decision making capability to your application.
-also known as conditional statements.
Relational Operators
-Compares values.
-Also known as comparison operator.
If Structure
-Executes a statement if the condition is true.
Syntax:
If condition Then
statement(s)
End If
Example:
1. Make an application that will asks a number and display its equivalent letter name.
2. Make an application that will add the two numbers if the first number is greater than the second
number.
Activity:
1. Make an application that will multiply two numbers if the second number is greater than the first
number.
If . . . Then. . . Else Structures
Executes statement or statements if the condition is true, executes another if the condition is false.
Syntax:
If condition Then
statement(s)
Else
statement(s)
End If
Example:
1. Make an application that will test if the inputted number is positive or negative.
Radio Button
Allows user to select one option from a list of options.
• Must be grouped.
• Use a maximum of six radio buttons per group.
Properties:
1. Name
2. Text
3. Checked
Checkbox
Allows user to select more than one option from a list of options.
• Must be grouped.
• Use a maximum of six checkboxes per group.
Properties:
1. Name
2. Text
3. Checked
ListBoxes
ListBoxes are used to select an item from a list of several options.
Properties:
1. Name
2. Add
3. Count
4. SelectedItem
5. SelectedIndex
6. Remove
ComboBoxes
A ComboBox is similar to a ListBox, but with some variations and some cool features.
ComboBoxes come in three styles: Simple, DropDown, and DropDownList.
1. Name
2. Add
3. Count
4. SelectedItem
5. SelectedIndex
Public Class Form1
Dim intFirstValue As Integer
6. Remove Dim intSecondValue As Integer
Dim strOperator As String
End Sub