Term
|
Definition
*Program statements executed in the order they appear |
|
|
Term
|
Definition
* Test for a condition being true or false
* Expression is called a Boolean expression because it evaluates to either true or false. If expression is true, execute statements...otherwise statements are skipped |
|
|
Term
|
Definition
Tests for various values of an expression |
|
|
Term
|
Definition
if decSales > 5000
MessageBox.Show("You've earned a bonus!")
End if |
|
|
Term
|
Definition
*Determines if a specific relationship exists between two values
> Greater than
< Less than
= Equal to
<> Not equal to
>= greater than or equal to
<= less than or equal to |
|
|
Term
|
Definition
*In a stand alone statement = is interpreted as assignment.
intUserNumber = 45
*In a Boolean expression = is interpreted as comparison
If intUserNumber = 45 Then |
|
|
Term
Function Calls in Expressions
|
|
Definition
If CInt(txtInput.Text) < 100 Then
lblMessage.Text = "It is true!"
End If |
|
|
Term
Boolean Variable As Expression |
|
Definition
If blnQuotaMet Then
lblMessage.Text = "You have met your sales quota"
End if
* Note that since a Boolean variable already evaluates to true or false, an = operator is not required |
|
|
Term
|
Definition
If expression Then
statements
Else
statments
End if
If decSales > 5000 Then
MessageBox.Show("You've earned a bonus!")
Else
MessageBox.Show("No bonus")
End If |
|
|
Term
|
Definition
If it is very cold Then
Wear a coat
Elseif it is chilly then
wear a light jacket
Elseif it is windy then
wear a windbreaker
Elseif it is hot then
wear no jacket |
|
|
Term
If...then..elself Order Matters |
|
Definition
*When a condition is true, the remaining conditions are ignored. |
|
|
Term
|
Definition
*The trailing else catches any value that falls through the cracks |
|
|
Term
|
Definition
*Any type of statement can be used inside an if, including another if statement. If statements within if statements creat a more complex decision structure.
If dblSalary>30000 then
If intYearsOnJob > 2 Then
lblMessage.Text = "Applicant qualifies."
Else
lblMessage.Text="Applicant does not qualify."
End if
End if |
|
|
Term
|
Definition
*We can combine two or more Boolean expressions into one.
If intTemperature <40 And strSeason = "Summer" Then
lblMessage.Text = "It is unusually cold."
End if
^^ Logical Operator |
|
|
Term
|
Definition
*Combines multiple Boolean expressions into a compound expression
*And, or , xor, not |
|
|
Term
|
Definition
both expressions must be true for overall expression to be true |
|
|
Term
|
Definition
one or both expression must be true for the overall expression to be true
If intTemperature < 20 or intTemperature > 100 then
lblMessage.Text = "Unsafe temperature"
End if |
|
|
Term
|
Definition
*Exclusive or
*One but not both expressions must be true for overall expression to be true |
|
|
Term
|
Definition
*Takes a Boolean Expression and reverses its logical value
*If the expression is true, the not operator returns false, and if the expression is false, it returns true.
Gives you the opposite |
|
|
Term
|
Definition
*Best for checking a value inside a range of numbers
If inx >= 20 ANd intX <=40 Then
lblMessage.Text = "The value is in the acceptable range."
End if |
|
|
Term
|
Definition
*Best for checking if a value is outside a range of numbers
If intX <20 Or intX > 40 Then
lblMessage.Text = "The value is outside the acceptable range."
End if |
|
|
Term
Precedence of Logical Operators |
|
Definition
From highest to lowest
1. not
2. and
3. or
4.xor |
|
|
Term
|
Definition
*relational operators can be used to compare strings and string literals
strName1 = "Mary"
strName2 = "Mark"
If strName1 = strName2 Then
lblMessage.Txt = "Name are the same"
Else
lblMessage.Text = "Names are not the same"
End if |
|
|
Term
|
Definition
If txtInput.Text = String.Empty Then
lblMessage.Text = "Please enter a value"
Else...... |
|
|
Term
|
Definition
*Converts string to upper or lower case letters
ToUpper
strLastName = txtLastName.Text.ToUpper()
ToLower
strBigTown = "NewYork"
strLittleTown = strBigTown.ToLower() |
|
|
Term
|
Definition
If txtInput.Text.Length >20 Then
lblMessage.Text = "Please enter no more than 20 characters."
End if |
|
|
Term
Removing Leading and Trailing Space |
|
Definition
TrimStart - returns the string with leading spaces removed
TrimEnd - returns the string with trailing spaces removed
Trim - returns the string with leading and trailing spaces removed
lblMessage1.Text = strGreeting.TrimStart() |
|
|
Term
|
Definition
*Returns a portion of a string
StringExpression.Substring(StartPos)
strFullName = "George Washington"
strLastName = strFullName.Substring(7) "Washington" |
|
|
Term
|
Definition
strFullName = "George Washington"
strFirstName= strFullName.Substring (0,6)
' George |
|
|
Term
|
Definition
*Searches for a specific string within a string
*Returns the position of the first occurrence of SearchString within StringExpression, or -1 if SearchString is not found |
|
|
Term
|
Definition
IndexOfstrFullName = "George Washington"
intPosition = strFullName.IndexOf("Wash,9)
will never a -1 because it's not true |
|
|
Term
|
Definition
strNumber = "567"
If IsNumeric (strNumber) Then 'returns true
strNumber = "567abc"
If IsNumeric(strNumber) Then 'returns false |
|
|
Term
VB Property vs Method vs Function |
|
Definition
*Property is accessed via the dot operator
strLastName.Length
*Method is accessed via the dot operator
strLastName.ToLower()
*No dot operator when calling a function
IsNumeric (strLastName) |
|
|
Term
|
Definition
*One of several possible actions is taken, depending on the value of an expression
Select Case CInt(txtInput.Text)
Case 1
MessageBox.Show ("Day 1 is Monday")
Case 2
MessageBox.Show("Day 2 is tuesday)
OR
If CInt(txtInput.Text) = 1 Then
MessageBox.Show ("Day 1 is Monday")
If CInt(txtInput.Text) = 2 Then
MessageBox.Show("Day 2 is tuesday) |
|
|
Term
When to use select case vs if |
|
Definition
*When you're testing multiple possbile alues of an expression you would use select case
If intApplicantAge<16 Then
MessageBox.Show("Applicant is too young"
Elseif strApplicantCounty<> Watuauga" Then
MessageBox.Show("Applicant must live in Watuagua") |
|
|
Term
|
Definition
*Method converts the string representation of a value to a specific data type. A return value indicates whether the conversion succeeded:
returns true if it was successful
false is failed
*Type.TryPasre(source, destination)
If Integer.TryParse(txtInput.Text, intNumber) Then
lblResult.Text = "Conversion Successful" |
|
|
Term
|
Definition
* is the process of inspecting user input to see whether it meets certain rules
|
|
|
Term
|
Definition
*Provides a quick and siple way to ask the user to enter data
*Should not be used as a primary method of input
Dim strUserName As String
strUserName = InputBox("Enter you name")
okay will return value
cancel with return empty string |
|
|
Term
|
Definition
*Controls displays a list of items and also allows the user to select one or more items from the list.
*Displays a scroll bar when all items cannot be shown
*Use lst prefix when naming a list box |
|
|
Term
|
Definition
*Items = entries in a list box are stored in a property name
*Collection = items is a special type of property |
|
|
Term
Items Collection
ListBox.Items.Insert.(Index,Item) |
|
Definition
*Items.Count = returns the number of items
*Items.Add() - adds an item at the end
*Items.Insert() - adds an items at specific position
*Items.Clear() - removes all items
*Items.Remove() removes specificed item
*Items.RemoveAt() removes at specificed index
*Items.Contains() - returns true if the collection contains the specified item, or false is if doesnt |
|
|
Term
|
Definition
If lstDogs.SelectedItem = "Boxer" Then
MessageBox.Show("You picked Boxer")
Else MessageBox.Show ("You chose another breed)
End if |
|
|
Term
|
Definition
If lstDogs.SelectedIndex = -1 Then
MessageBox.Show ("no item is selected")
end if |
|
|
Term
|
Definition
*A boolean property
*When set to true values in the item property are displayed in aplhabetical order
*When set to false, values in the items property are displayed in the order they were added
*Set to false by default |
|
|
Term
|
Definition
*Repetition structure or loop causes one or more statements to repeat
*Each reprtition of the loop is = iteration
Three types:
1.do while
2.do until
3.for next |
|
|
Term
|
Definition
**A boolean expression that is tested for a true or false value
*a statement or group of statements that is repeated as long as the boolean expression is true
Dim intCount As Integer = 0
Do While intCount <10
lstOutput.Items.Add ("Hello")
intCount += 1
Loop
|
|
|
Term
|
Definition
*A loop must have some way to end itself
*If the test expression can never be false, the loop will continue to repeart forever |
|
|
Term
|
Definition
*A variable that is incremented or decremented in each loop interation
* Increment means add 1
*Decrement means to subtract 1 |
|
|
Term
|
Definition
*Iterates until the expression is true
|
|
|
Term
|
Definition
* Loop the expression is tested before the body is executed
Do While intCount<10
lstOutput.Items.Add("hello")
intCount += 1
Loop
|
|
|
Term
|
Definition
*Loop the body is executed before expression is tested
Do
lstOutput.Items.Add("Hello")
intCount += 1
Loop while intCount <10 |
|
|
Term
|
Definition
*Ideal for loops that require a counter
*Pretest form only
For intCount = 0 to 9
lstOutput.Items.Add ("Hello")
Next |
|
|
Term
|
Definition
*Is the value added to the counter variable at the end of each iteration. If not specified it defaultss to 1
For inCount = 0 to 100 Step 10
MessageBox.Show(intCount.ToString())
Next
counts as 0,10,20,30,40....100 |
|
|
Term
|
Definition
*Exit do : used in do while or do until
*Exit for : used in for next loops
caution it can be difficult to debug
Dim strInput As String
Do Until strInput = "John"
strInput = InputBox("What is the password")
If strInput = " " Then
Exit Do
End If
Loop |
|
|
Term
|
Definition
*For ..Next = when the number or required iterations is known
*Do while = when you wish the loop to repeat as long as the test expression is true
*Do until = when you wish the loop to repeat as long as the test pression is false |
|
|
Term
|
Definition
*Loop insidde another loop
For intSeconds = 0 to 59
lblSeconds.Text = intSeconds.ToString()
Next
For intSeconds = 0 to 59
lblSeconds.Text = intSeoncds.ToString() |
|
|
Term
|
Definition
* Boolean property with default alue of false
*If set to true, entries can appear side by side
|
|
|
Term
|
Definition
*Variation of the listbox contril with a checkbox beside each item
*Determines how items may be checked.
False = user clickess item once to select it again to check it
True - user clicks item only once to both selet it and check it
|
|
|
Term
|
Definition
Dim intIndex As Integer
For inIndex = 0 To clbToppings.Items.Count - 1
If clbToppings.GetItemChecked (intIndex) Then
MessageBox.Show(clbToppings.Items (intIndex) + " is checked"
End if
Next |
|
|
Term
|
Definition
*Method to set the checked state of each item in code.
Dim intIndex As Integer
For intIndex = 0 To clbToppings.Items.Count - 1
clbToppings.SetItemChecked (intIndex, False)
Next |
|
|
Term
|
Definition
*A cobination of a ListBox and a TextBox
*You can allow the user to either choose an item from the list or type in a value
*Simple = visible, editable, type in a value and not limited to selecting what is there
*DropDown = click down arrow, editable
DropDownList = click down arrow, not editable |
|
|
Term
|
Definition
*Random.Net get a random integer nuber in the range minValue to maxValue
intNum= rand.Next (0,100) |
|
|
Term
|
Definition
With textName
.clear()
.ForeColor = Color.Blue
.BackColor = Color.Yellow
End With |
|
|
Term
|
Definition
*Appears in the compnent tray, not the form
*Resizable region at the bottom of the designer window that holds invisible controls
|
|
|
Term
|
Definition
*AutoPopDelay = determines how long a tip is displayed
*InitialDelay = regulates the delay before a tip appears
*ReshowDelay = determines the time between the display of different tips as the user moves the mouse from control to control
*AutomaticDelay = sets the above 3 properties alll at once |
|
|
Term
|
Definition
*Payment returns the periodic payment amount for a loan with a fixed interest rate
dblPayment = Pmt(dblAnnInt / 12, Number of Periods, loan amount which must be negative)
3 parts |
|
|
Term
|
Definition
*Function returns the interest portion for a specific period of a loan with a fixed interest rate and fixed monthly payment
IPmt (PeriodsInterestRate, 12, Number of periods, -loan amount)
4 parts |
|
|
Term
|
Definition
*Funcion returns the principal portion for a specific period of a loan with a fixed interest rate and fixed monthly payments
dblPrincipal = PPmt (dblAnnInt /12, Number of periods, -loan amount)
4 parts |
|
|
Term
|
Definition
*The sume of the interest portion and principal portion will equal the total payment :
total payment = (interest portion)+(principal portion)
|
|
|