Answer to Question #268693 in Visual Basic for Maika Togavuto

Question #268693

  Using implicit sizing, assign the integers 2, 3, 5, 7, 11, and 13 to an array named intPrimeNumbers. 

2.       Answer the following questions about the following initialized array: Dim strSeafood(8) as String 

           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”


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
Expert's answer
2021-11-19T10:01:00-0500


Question 1:


Dim intPrimeNumbers() As Integer = {2, 3, 5, 7, 11, 13}


Question 2:
Module Module1
    Sub Main()
        Dim strSeafood(8) As String
        'a. Assign Oysters to the first array location. What is the index number? Answer: ZERO
        strSeafood(0) = "Oysters"
        'b. Assign Lobster to the fourth location in the array. What would the assignment statement look like?
        strSeafood(3) = "Lobster"
        'c. What value does strSeafood.Length have? Answer: 9
        Console.WriteLine(strSeafood.Length.ToString())
        'd. How many types of seafood can this array hold? Answer: one type String
        'e. What would happen if you assigned strSeafood(9) = “Red Snapper”? 
        'Answer:An IndexOutOfRangeException exception is thrown when an invalid index is used to access a member of an array or a collection
        strSeafood(9) = "Red Snapper"


        Console.ReadLine()
    End Sub
End Module


Question 3:




Imports System.IO




Module Module1








    Sub Main()
        Dim strFordModel(1000) As String
        Dim intCount As Integer = 0
        Dim objReader As StreamReader
        objReader = New StreamReader("Model.txt")




        Do While objReader.Peek <> -1
            strFordModel(intCount) = objReader.ReadLine()
            intCount += 1
        Loop
        objReader.Close()
        For i As Integer = 0 To intCount - 1
            Console.WriteLine(strFordModel(i))
        Next








        Console.ReadLine()
    End Sub
End Module


Question 4:




Public Class Form1


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim strSongNames() As String = {"AC/DC Current", "Act Naturally", "Afro Puffs"}


        For Each strPlay In strSongNames
            lstDisplay.Items.Add(strPlay)
        Next


    End Sub
End Class

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS