Wednesday, February 25, 2009

FeB 25th work.

Justin F



- Explain the process of naming a variable, declaring a variable, assigning a variable.

- When naming a variable you want to make the name similar to the object so that you know what it is.
EX.) I have a button with a value of Exit. I would name it something like exitButton, or exitBtn.

- When declaring a Variable you say: Dim name As String, Integer, or Decimal

- When you want to assign a variable to something you use: name of variable = text or object.

-Review Practice: Chapter 3

Short answer-

Questions - pg. 188 - 189

1. Assume a procedure needs to store an item's name and its price. The price may have a decimal place. Write the appropriate Dim statements to create the necessary procedure-level variables.

Dim items name as String
Dim price name as Decimal
Dim isconverted as Boolean
isConverted = Decimal.Tryprase(textboxname, )


2. Assume a procedure needs to store the name of an item in inventory and its height and weight. The height has decimal places; the weight will be whole numbers only. Write the appropriate Dim statements to create the necessary procedure-level variables.

Dim nameofinventoryitem As String
Dim heightofitem As Decimal
Dim weightofitem As Integer
Dim isconverted> As Boolean


3. Write an assignment statement that assign Miami to an existing String variable named city.

Dim cityName As String
cityName = textbox1.Text

cityLabel.Text = cityName


4. Write an assignment statement that adds the contents of the sales1 variable to the contents of sale2 variable, and then assigns the sum to an existing variable named totalSales. All of the variables have the Decimal data type.


Dim sales1 As Decimal
Dim sales2 As Decimal
Dim totalSales As Decimal

sales1 = content
sales2 = content
totalSales = sales1 + sales2

Label1.Text = totalSales


5. Write an assignment statement that multiplies the contents of the salary variable by the number 1.5, and then assign the result to the salary variable. The salary variable has the Decimal data type.


Dim getsalary As Decimal
Dim salary As Decimal
Const times As Decimal = 1.5

salary = getsalary * times


6. Assume a form contains 2 buttons named salarybutton and bonusbutton. Both buttons Click event procedures need to use the same variable, which is a string variable named employeeName. Write the appropriate statement to declare the employeeName Variable. Also specify where you will need to enter the statement and whether the variable is a procedure-level or module-level variable.


Dim employeeName As String

employeeName = employeeNameTextBox.Text

Public Sub salaryButton_Click()
If employeeName == name Then
MessageBox.Show(employeeName & "salary is amount)
Else
MessageBox.Show("You did not enter name.")
End If
End Sub


9. Write the statement to convert the contents of the unitsTextBox to an integer. Store the Integer is an Integer Variable named numberofunits. Us isConverted as the name of the Boolean.


Dim unitsenter As String
Dim numberofunits As Integer
Dim isConverted As Boolean

unitsenter = unitsTextBox.Text
isConverted = Integer.TryParse(unitsenter, numberofunits)



15. What is a static Variable?

Is a procedure-level variable that retains its value even when the procedure in which it is declared ends.

Chapter 3 -> Pg.260 Writing Statements
Chapter 4 -> Pg.260

7. Write an If...Then...Else statement that displays the string "Pontiac" in the carmakerLabel when the carTextBox contains the string "Grand Am".


Dim carname As String
carname = carTextBox.Text

If carname = "Grand Am" Then
carMakerLabel.Text = "Pontiac"
Else
MsgBox("NO RIGHT")
carMakerLabel.Text = " "
End If


8. Write an If..Then..Else statement that displays the string "Entry error" in the message Label then the units variable contains a number that is less than 0; Otherwise, assign the String "OK".


Dim numberenter As Integer
Dim error As String = "Entry Error"
Dim passes As String = "OK"
Dim isConverted As Boolean

isConverted = Integer.TryParse(NumberTextBox.Text, numberenter)

If numberenter < 0 Then
MessageLabel.Text = error
Else
MessageLabel.Text = passes
End If


13.


Dim hours As Integer
Dim hourRate As Integer
Dim gross As Integer

If hours = 40 Then
gross =
ElseIf hours > 40 Then
gross = number + hourRate
End If

Tuesday, February 24, 2009

Justin F

1. A - price > 500d orElse <800d
2. C - first nameTextbox. text.toupper90 = "Bob"
3. B - False
4. B - False
5. A - True
6. C - Paul
7. B - Jerry
8. C - Paul
9. D - Sue
10. C - either the true path or the false path
11. D - All of the above
12. C - Paul
13. C - Paul
14. B - Jerry
15. A - Advance.NewLine
16. D - string.innullOrEmpty(Cityname)
17. C - MessageBox.ok
18. B - randomgenerator.next(10,55)
19. C - addresslabel.Text = city 7 '' ' " $ state
20. B - case 1 to 5

Wednesday, February 18, 2009

Work Feb 18th.

Justin F - Period 1.

Comparison Operators:
1. If temperature > 75
Display temperature
endif
2. If GPA > 2.5
Display GPa
Else
Print “You Need to Improve your GPA”
endif

Comparison Operators:

1. If variable1 = variable2 Then
Condition = True
endif
2. If name <> Smith Then
Display allNames
endif
3. If taxRate > 7%
price * .99
Display taxRate
endif

Upper/Lower Methods:

1. nameSmith = nameSmith.ToLower()
2. nameSmith = nameSmith.ToUpper()

= equals
> greater than
>= greater than or equal
< less than
<= less than or equal
<> not equal to

Summary - Decision Structure or Selection structure is a structure comprised of If, If/Then, If/Then/Else, and Case structures. Each of these structures has a "true" path defined by the "condition" yet only some of them may contain a "false" path recognized my the operator "else". The operator "endif" represents the ending of the statement. If statements primarily use Comparison Operators or Relational Operators to define s true statement. These operators include =,<,>,<=,>=,and <>. The Upper method and the Lower methods are coding methods added to change a string from upper case to lower case or vice-versa.

Thursday, February 12, 2009


Justin F - Self Work.


1.C. Variables
2. D. All names are valid
3.C. Procedure-level
4.A. literal constant
5.B. Literal Variable
6.B. Integer
7.B. price = 2.89D
8.C. isConverted = TryParse.Decimal(inputRate, rate)
9.A. answerTextBox.Text = Convert.ToString(score1 + score2)
10.D. commission = Convert.ToSingle(sales) * .05S
11.A. Const Rate As Double = .09
12.A. totalLabel.text = Convert.ToInteger(num1 + num2)
13.B. asterisk

14.B. Module-level
15.C. Option Implicit Off
16.B. numberTextBox.SendFocus()
17.C. nameTextBox.Text = “Jonas”
18.B. Syntax error
19.C. Correct instruction
20.A. salesLabel.Text = sales.ToString(“C2”)

Thursday, February 5, 2009

Work From 2-05-09

Data Type- determines the type of data a variable can store.

Boolean Variables – computer memory locations where programmers can temporarily store data while an application is running.

String – a group of characters enclosed in quotation marks

Method – a specific portion of the class instructions and its purpose is to perform a task for the class

Import System. Globalization – imports the System. Globalization namespace, which contains the definitions for the numberStyles and numberFormatInfo.CurrentInfo values

Floating point- is a number that is expressed as a multiple of some power of 10

Unicode – the universal coding scheme for characters

Identifier- the name of an object

Dim – dimension; A method to declare a variable in Visual Basic.

Literal constant - an item do data whose value does not change while the application is running

Literal type character - a character used to convert a literal constant to a different data type

TryPase Method – a method used to convert a string to that numeric data type.

Line continuation character – an underscore, which must be preceded by a space; used to break up a long instruction into two or more physical lines in the Code Editor window

Convert class - this class contains methods that return the result of converting a value to a specified data type

Precedence Numbers – indicate the order in which the computer performs an operation (such as an arithmetic operation) in an expression

Operators-mathematical symbols used in calculations, +-*/

Scope- indicates where a variable can be used in the application’s code.

Lifetime - indicates how long a variable remains in the computer’s internal memory
Procedure scope - the scope of a procedure-level variable

Comments – used to document a program internally; created using the apostrophe

Module scope- refers to the scope of a model-level variable, which can be used by all of the procedures in the current form

Block scope - the scope of block-level variables, which can be used only within the statement block in which they are declared

Static variable – a procedure-level variable that retains its value when the procedure ends

Option Explicit – Disables implicit declaration of variables

Option strict- strings will not be implicity converted to numbers, and vice versa, narrower data types will be promoted to wider data types, wider data types will not be demoted to narrower.

Pseudocode - uses phrases to describe the steps a procedure needs to take to accomplish its goal

Empty String – a set quotations marks with nothing between them; also called a zero-length string

Focus method- used to move the focus to a control while an application is running

Format specifier - determines the special characters that will appear in a formatted number.

Questions:

How do you name a variable and provide one example.

-You can name it in a way that it doesn’t conflict with other commands. (no spaces or special characters) EX: RedBikes

How do you declare a variable and provide one example.

-You can declare a variable by using the DIM command. EX: Dim RedBikes As Integer

What is the difference between DIM and Const?

-Dim is a variable that can be changed, while Const is a variable that is only named once and it stays the same. EX: Const TaxtRate As Decimal = 0.10D

How do you include a mathematical expression in assignment statements?

-you use variables. totalSkate= RedBikes + BlueBikes

How do you clear the text property when application is running?

-you use the clear function. redTextBox.Clear()

How do you format a number for output as a string?

-You use the convert.Tostring function. EX: totalBoardsLabel.Text = Convert.ToString(totalSkateBoards)