3. Study the following code. what messages will be displayed in the message box?
Dim intCounter As Integer
Dim dblSum As Double, dblNumber As Double
dblSum = 0
intCounter = 1
Do While intCounter < 6
dblSum = dblSum + Convert.ToDouble(intCounter)
If intCounter Mod 3 = 0 Then
dblNumber = 5.0
End If
dblSum = dblSum + dblNumber
intCounter = intCounter + 2
Loop
MessageBox.Show("The Sum is: " & dblSum.ToString(),"IS122")
4. Rewrite the following section of code using a For Next loop instead of a Do While loop.
Dim intSum As Integer
int intCount As Integer
intCount = -5
Do While intCount <= 15
intSum = intSum + intCount
intCount = intCount + 1
Loop
1. Consider the following code segments using the Boolean variables a, b, c and d.
If Not c Or d Then
If a And c Then
lblOut.Text = “1”
ElseIf b Then
lblOut.Text = “2”
Else
lblOut.Text = “3”
End If
ElseIf Not c = d Then
lblOut.Text = “4”
ElseIf c Then
lblOut.Text = “5”
Else lblOut.Text = “6”
End If
a. Give the values for a, b, c and d that will cause the above code segment to display 1 in lblOut.
b. Give the values for a, b, c and d that will cause the above code segment to display 4 in lblOut.
2. Write VB.NET code that will use a loop to calculate the sum of all integer numbers between 5 and 100 that are divisible by both 5 and 6.
You may choose to use any looping structure.
Use the following variable declarations.
Dim intCounter As Integer ‘loop counter variable
Dim intSum As Integer ‘to accumulate the summation
Answer the following questions about the following initialized:
Dim strPacificCapitals(11) As String
a. Assign Apia to the first array location. What is the index number?
b. Assign Honiara to the fourth location in the array. What would the assignment statement looks like?
c. What value does strPacificCapitals.Length have?
d. How many capitals can this array hold?
e. What would happen if you assigned strPacificCapitals(11) = “Port Vila”?
1) Write a procedure that will compute and return the average of three numbers. The procedure should have three parameters of type double representing the numbers to be averaged. (for example the average of x, y and z is given by (x+y+z)/3.0)
2) what is the output of the following code?
Private Sub btnBedrockClick(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim strFullName As String = “Jonah Lomu”
Dim strSecondName As String = “Va’inga Tuigamala”
CountLength(strFullName, strSecondName) lblEnd.Text = “My favorite was ” & strSecondName
End Sub
Private Sub CountLength(ByVal strFullName As String, ByRef strSecondName As String)
lblFirst.Text = “The first name has ” & strFullName.Length & “ letters.” lblSecond.Text = “The second name has ” & strSecondName.Length & “ letters.”
strSecondName = “Joe Rokocoko”
End Sub
Write a For Each loop that displays every element of an array named strSongNames in a ListBox named lstDisplay. The loop variable is named strPlay
Rewrite the following code to read each line of a text file into an array named strFordModel. Just write the correct code. Do While objReader.Peek = -1 strFordModel(intCount) = objReader.ReadLine intCount += 1 Loop
How to code procedures in a form to : i. A function that calculates average score. ii. Another function that determines the minimum score. iii. And another to determine the maximum score.
how to code button titled Open Student Details File.
When this button is clicked, do following: a) Open and read StudentDetails.txt and store the data into a StudentDetails structure array.
code for:
Put a button titled Open Answers File. When this button is clicked; open Answer.txt, and read and store the answers in an array of Strings. Close this file.
1. Using implicit sizing, assign the integers 2, 3, 5, 7, 11, and 13 to an array named intPrimeNumbers. (1 mark)
2. Answer the following questions about the following initialized array: Dim strSeafood(8) as String (2.5 marks)
a. Assign Oysters to the first array location. What is the index number?
b. Assign Lobster to the fourth location in the array. What would the assignment statement look like?
c. What value does strSeafood.Length have?
d. How many types of seafood can this array hold?
e. What would happen if you assigned strSeafood(9) = “Red Snapper”?
3. Rewrite the code below to read each line of a text file into an array named strFordModel. ( 0.5 marks)
4. Write a For Each loop that displays every element of an array named strSongNames in a ListBox named lstDisplay. The loop variable is named strPlay. (1 Mark)