Lab Answer Key - Module 2 - Using Visual Basic Programming Constructs
Lab Answer Key - Module 2 - Using Visual Basic Programming Constructs
Click Start, point to All Programs, click Microsoft Visual Studio 2010, and
then click Microsoft Visual Studio 2010.
b. In the New Project dialog box, in the left pane, expand Visual Basic, and
then click Windows.
d. Specify the following values for each of the properties in the dialog box,
and then click OK:
Name: SquareRoots
Location: D:\Labfiles\Lab02\Ex1\Starter
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3&F 1/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
1. Add a TextBox, a Button, and two Label controls to the MainWindow window.
Place them anywhere in the window.
2. Using the Properties window, set the properties of each control by using the
values in the following table. Leave any other properties at their default values.
Height 28
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3&F 2/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
HorizontalAlignment Left
Margin 12,12,0,0
Text 0.00
VerticalAlignment Top
Width 398
Content Calculate
Height 23
HorizontalAlignment Right
Margin 0,11,12,0
VerticalAlignment Top
Width 75
Height 28
HorizontalAlignment Left
Margin 12,41,0,0
VerticalAlignment Top
Width 479
Height 28
HorizontalAlignment Left
Margin 12,75,0,0
VerticalAlignment Top
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3&F 3/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
Width 479
b. In the Properties window, click the text, textBox1, adjacent to the TextBox
prompt, and then change the name to InputTextBox.
c. In the list of properties in the Properties window, locate the Height property,
and then change it to 28.
d. Repeat this process for the remaining properties of the TextBox control.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3&F 4/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
Task 3: Calculate square roots by using the Math.Sqrt method of the .NET
Framework.
2. In the CalculateButton_Click method, add code to read the data that the user
enters in the InputTextBox control, and then convert it into a Double. Store the
double value in a variable named, numberDouble. Use the TryParse method of
the Double type to perform the conversion. If the text that the user enters is not
valid, display a message box with the text, "Please enter a double.", and then
execute a Return statement to exit the method.
Return
End IfEnd Sub
3. Check that the value that the user enters is a positive number. If it is not, display
a message box with the text, "Please enter a positive number.", and then return
from the method.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3&F 6/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
CalculateButton.Click
...
' Check that the user has entered a positive
number
If numberDouble <= 0 Then
MessageBox.Show("Please enter a positive
number")
Return
End IfEnd Sub
4. Calculate the square root of the value in the numberDouble variable by using
the Math.Sqrt method. Store the result in a double variable named,
squareRoot.
5. Format the value in the squareRoot variable by using the layout shown in the
following code example, and then display it in the FrameWorkLabel Label
control.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3&F 7/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
Use the String.Format method to format the result. Set the Content property of
a Label control to display the formatted result.
End Sub
At this point, your code should resemble the following code example.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3&F 8/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
Then
MessageBox.Show("Please enter a double")
Return
End If
Return
End If
6. Build and run the application to test your code. Use the test values that are
shown in the following table, and then verify that the correct square roots are
calculated and displayed (ignore the "Using Newton" label for the purposes of
this test).
25 5
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3&F 9/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
625 25
0.00000001 0.0001
10 Message box appears with the message "Please enter a positive number."
Fred Message box appears with the message "Please enter a double."
10 3.16227766016838
8.8 2.96647939483827
2.0 1.4142135623731
2 1.4142135623731
a. Press Ctrl+F5.
b. Enter the first value in the Test value column in the table in the TextBox control,
and then click Calculate.
c. Verify that the result matches the text in the Expected result column.
1. In the CalculateButton_Click method, after the code that you added in the
previous task, create a decimal variable named, numberDecimal. Initialize this
variable with the data that the user enters in the InputTextBox control, but
convert it into a Decimal this time (previously, you read it as a Double). If the
text that the user enters is not valid, display a message box with the text, "Please
enter a decimal.", and then run a Return statement to exit the method.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 10/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
Append the code in the following code example to the end of the
CalculateButton_Click method.
If Not Decimal.TryParse(InputTextBox.Text,
numberDecimal) Then
MessageBox.Show("Please enter a decimal")
Return
End IfEnd Sub
Note: This step is necessary because the Decimal and Double types
have different ranges. A
number that the user enters that is a valid Double might be out of range for the
Decimal type.
2. Declare a decimal variable named, delta, and initialize it to the value of the
expression, Math.Pow(10, 28). This is the smallest value that the Decimal type
supports, and you will use this value to determine when the answer that is
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 11/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
Note: The Math.Pow method returns a double. You will need to use the
Convert.ToDecimal method to convert this value to a decimal before
you assign it to the delta variable.
3. Declare another Decimal variable named, guess, and initialize it with the initial
guess at the square root. This initial guess should be the result of dividing the
value in numberDecimal by 2.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 12/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
4. Declare another decimal variable named, result. You will use this variable to
generate values for each iteration of the algorithm, based on the value from the
previous iteration. Initialize the result variable to the value for the first iteration
by using the expression, ((numberDecimal / guess) + guess) / 2.
5. Add a While loop to generate further refined guesses. The body of the While
loop should assign result to guess, and generate a new value for result by
using the expression, ((numberDecimal / guess) + guess) / 2. The While loop
should terminate when the difference between result and guess is less than or
equal to delta.
Note: Use the Math.Abs method to calculate the absolute value of the
difference between result and guess. Using Newton's algorithm, it is
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 13/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
possible for the difference between the two variables to alternate between
positive and negative values as it diminishes. Consequently, if you do not
use the Math.Abs method, the algorithm might terminate early with an
inaccurate result.
6. When the While loop has terminated, format and display the value in the result
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 14/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
variable in the NewtonLabel control. Format the data in a similar manner to the
previous task.
Return
End If
Return
End If
Return
End If
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 16/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
-28))
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 17/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
1. Build and run the application in Debug mode to test your code. Use the test
values shown in the following table, and verify that the correct square roots are
calculated and displayed. Compare the value in the two labels, and then verify
that the square roots that are calculated by using Newton's method are more
accurate than those calculated by using the Math.Sqrt method.
25 5 5.000000000000000000000000000
625 25 25.000000000000000000000000000
10 3.16227766016838 3.1622776601683793319988935444
2 1.4142135623731 1.4142135623730950488016887242
b. Enter the first value in the Test value column in the table in the TextBox control,
and then click Calculate.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 18/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
b. In the New Project dialog box, in the Project Types pane, expand Visual Basic,
and then click Windows.
d. Specify the following values for each of the properties in the dialog box, and
then click OK.
Name: IntegerToBinary
Location: D:\Labfiles\Lab02\Ex2\Starter
1. Add a TextBox, Button, and Label control to the MainWindow window. Place
them anywhere in the window.
2. Using the Properties window, set the properties of each control by using the
values in the following table. Leave any other properties at their default values.
Height 28
HorizontalAlignment Left
Margin 12,12,0,0
Text 0
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 20/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
VerticalAlignment Top
Width 120
Content Convert
Height 23
HorizontalAlignment Left
Margin 138,12,0,0
VerticalAlignment Top
Width 75
Content 0
Height 28
HorizontalAlignment Left
Margin 12,41,0,0
VerticalAlignment Top
Width 120
b. In the Properties window, click the text, textBox1, adjacent to the TextBox
prompt, and then change the name to InputTextBox.
c. In the list of properties in the Properties window, locate the Height property,
and then change it to 28.
d. Repeat this process for the remaining properties of the TextBox control.
f. Follow the procedure described in steps b to d to set the specified properties for
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 21/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
this control.
h. Follow the procedure described in steps b to d to set the specified properties for
this control.
j. Follow the procedure described in steps b to d to set the specified properties for
this control.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 22/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
2. In the ConvertButton_Click method, add code to read the data that the user
enters in the InputTextBox control, and then convert it into an Integer type.
Store the integer value in a variable named, i. Use the TryParse method of the
Integer type to perform the conversion. If the text that the user enters is not
valid, display a message box with the text, "TextBox does not contain an
integer.", and then execute a Return statement to exit the method.
If Not Integer.TryParse(InputTextBox.Text, i)
Then
MessageBox.Show("TextBox does not contain an
integer")
Return
End IfEnd Sub
3. Check that the value that the user enters is not a negative number (the integer-
to-binary conversion algorithm does not work for negative numbers). If it is
negative, display a message box with the text, "Please enter a positive number or
zero.", and then return from the method:
step.
Return
End IfEnd Sub
4. Declare an integer variable named, remainder, and initialize it to zero. You will
use this variable to hold the remainder after dividing i by 2 during each iteration
of the algorithm.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 24/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
5. Declare a StringBuilder variable named, binary, and instantiate it. You will use
this variable to construct the string of bits that represent i as a binary value.
Import the System.Text namespace by using the Error Correction Options
dialog box. You can do this by placing the cursor over the last character, r, in the
text, StringBuilder, move the cursor over the exclamation icon, click the drop-
down arrow, and then click Import 'System.Text'.
b. Place the cursor over the last character, r, in the text, StringBuilder, move
the cursor over the exclamation icon, click the drop-down arrow, and then
click Import 'System.Text'.
a. Calculates the remainder after dividing i by 2, and then stores this value in
the remainder variable.
c. Prefixes the value of remainder to the start of the string being constructed
by the binary variable.
Note: To prefix data into a StringBuilder object, use the Insert method
of the StringBuilder class, and then insert the value of the data at
position 0.
7. Display the value in the binary variable in the BinaryLabel Label control.
Note: Use the ToString method to retrieve the string that the
StringBuilder object constructs.
Set the Content property of the Label control to display this string.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 26/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
Return
End If
' Check that the user has not entered a negative number
If i < 0 Then
MessageBox.Show("Please enter a positive number or zero")
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 27/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
Return
End If
Loop
1. Build and run the application to test your code. Use the test values shown in the
following table, and verify that the binary representations are generated and
displayed.
1 1
1 Message box appears with the message, "Please enter a positive number or zero."
10.5 Message box appears with the message, "TextBox does not contain an integer."
Fred Message box appears with the message "TextBox does not contain an integer."
4 100
999 1111100111
65535 1111111111111111
65536 10000000000000000
a. Press Ctrl+F5.
b. Enter the first value in the Test value column in the table in the TextBox control,
and then click Convert.
c. Verify that the result matches the text in the Expected result column.
Task 1: Open the MatrixMultiplication project and examine the starter code.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 29/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
D:\Labfiles\Lab02\Ex3\Starter folder.
The user interface contains three Grid controls, three ComboBox controls, and a
Button control. When the application runs, the first Grid control, labeled, Matrix
1, represents the first matrix, and the second Grid control, labeled, Matrix 2,
represents the second matrix. The user can specify the dimensions of the
matrices by using the ComboBox controls, and then enter data into each cell in
them. There are several rules that govern the compatibility of matrices to be
multiplied together, and Matrix 2 is automatically configured to have an
appropriate number of rows based on the number of columns in Matrix 1.
When the user clicks the Calculate button, Matrix 1 and Matrix 2 are multiplied
together, and the result is displayed in the Grid control labeled, Result Matrix.
The dimensions of the result are determined by the shapes of Matrix 1 and
Matrix 2.
The following image shows the completed application running. The user has
multiplied a 23 matrix with a 32 matrix, and the result is a 33 matrix.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 30/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
Task 2: Define the matrix arrays and populate them with the data in the Grid
controls.
1. In Visual Studio, review the Task List. You can view the Task List from the View
menu, where you point to Other Windows, and then click Task List. If the Task
List displays User Tasks, in the drop-down list box, click Comments.
a. If the Task List is not already visible, on the View menu, point to Other
Windows, and then click Task List.
b. If the Task List displays User Tasks, in the drop-down list box, click
Comments.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 31/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
3. At the top of the MainWindow class, remove the comment TODO: Task 2
declare variables, and then add statements that declare three two-dimensional
arrays named, matrix1, matrix2, and result. The type of the elements in these
arrays should be Double, and the size of each dimension should be set to 0,
because the arrays will be dynamically sized, based on the input that the user
provides. The first dimension will be set to the number of columns, and the
second dimension will be set to the number of rows.
Class MainWindow
' Declare three arrays of doubles to hold the 3 matrices:
' The two input matrices and the result matrix
Private matrix1(0, 0) as Double
Private matrix2(0, 0) as Double
Private result(0, 0) as Double ...
End Class
4. In the Task List, double-click the task TODO: Task 2 Copy data from input
Grids. This task is located in the CalculateButton_Click method.
System.Windows.RoutedEventArgs)
' Retrieve the contents of the first two grids
' into the first two matrices
getValuesFromGrid(Matrix1Grid, matrix1)
getValuesFromGrid(Matrix2Grid, matrix2) ...
End Sub
6. Remove the comment TODO: Task 2 Get the matrix dimensions. Declare three
integer variables named, m1columns_m2rows, m1rows, and m2columns.
Initialize m1columns_m2rows with the number of columns in the matrix1 array
(this is also the same as the number of rows in the matrix2 array) by using the
GetLength method of the first dimension of the array. Initialize m1rows with the
number of rows in the matrix1 array by using the GetLength method of the
second dimension of the array. Initialize m2columns with the number of
columns in the matrix2 array.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 33/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
...
End Sub
Task 3: Multiply the two input matrices and calculate the result.
Next ...
End Sub
2. In the body of the For loop, add a nested For loop that iterates through all the
columns in the matrix2 array. Use an integer variable named, column, as the
control variable in this For loop. Leave the body of this For loop blank.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 34/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
' Calculate the value for each cell in the result matrix
For row As Integer = 0 To m1rows - 1
For column As Integer = 0 To m2columns - 1
Next Next
...
End Sub
3. The contents of each cell in the result array are calculated by adding the product
of each item in the row identified by the row variable in matrix1 with each item
in the column identified by the column variable in matrix2. You will require
another loop to perform this calculation, and a variable to store the result as this
loop calculates it.
In the inner For loop, declare a Double variable named, accumulator, and then
initialize it to zero. Your code should resemble the following code.
' Calculate the value for each cell in the result matrix
For row As Integer = 0 To row < m1rows
For column As Integer = 0 To m2columns - 1
' Initialize the value for the result cell
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 35/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
4. Add another nested For loop after the declaration of the accumulator variable.
This loop should iterate through all the columns in the current row in the matrix1
array. Use an integer variable named, cell, as the control variable in this For loop.
Leave the body of this For loop blank.
' Calculate the value for each cell in the result matrix
For row As Integer = 0 To row < m1rows
For column As Integer = 0 To m2columns - 1
' Initialize the value for the result cell
Dim accumulator As Double = 0
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 36/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
5. In the body of this For loop, multiply the value in matrix1(cell, row) with the
value in matrix2(column, cell), and then add the result to accumulator.
' Calculate the value for each cell in the result matrix
For row As Integer = 0 To row < m1rows
For column As Integer = 0 To column < m2columns
' Initialize the value for the result cell
Dim accumulator As Double = 0
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 37/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
6. After the closing of the innermost For loop, store the value in the accumulator in
the result array. The value should be stored in the cell that the column and row
variables have identified.
' Calculate the value for each cell in the result matrix
For row As Integer = 0 To row < m1rows
For column As Integer = 0 To m2columns - 1
' Initialize the value for the result cell
Dim accumulator As Double = 0
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 38/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 39/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
Press Ctrl+F5.
5. Specify the values for the cells in the matrices as shown in the following tables.
Matrix 1
1 5 9
3 7 11
Matrix 2
2 8 14
4 10 16
6 12 18
6. Click Calculate. Verify that the Result matrix displays the values as shown in in
the following table.
Result
32 50 68
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 40/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
44 86 128
Matrix 2
1 0 0
0 1 0
0 0 1
8. Click Calculate. Verify that the Result matrix displays the values as shown in the
following table.
Result
1 5 9
3 7 11
Matrix 2
1 0 0
0 1 0
0 0 1
10. Click Calculate. Verify that the Result matrix displays the values in the following
table.
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 41/42
10/4/2014 Lab Answer Key: Module 2: Using Visual Basic Programming Constructs
Result
1 5 9
3 7 11
This time, the values in Result are the same as those in Matrix 1, except that the
sign of each element is inverted (Matrix 2 is the matrix equivalent of 1 in
regular arithmetic).
https://skillpipe.courseware-marketplace.com/reader/en-GB/Book/BookPrintView/b932d846-d99f-4edd-a713-e6e2d97c4a9c?ChapterNumber=19&FontSize=3& 42/42