Answer to Question #268009 in Visual Basic for ray

Question #268009



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-24T13:49:20-0500
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 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