I am very stuck. I need to write a prog that uses arrays and receives the length and the width of a multiroom building and find the area needed for for the carpet or wood flooring. This is just the first part and thisis as far as I am able to go/understand. Any help would greatly appreciated, Thank You.

Public Class Form1
    Dim dimensions() As Integer
    Dim rooms As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim prompt1, prompt2, title As String
        Dim i As Short
        prompt1 = "Enter the length of the room"
        prompt2 = "Enter the width of the room"
        rooms = InputBox("How many rooms?", "Create Array")

        If rooms > 0 Then ReDim dimensions(rooms - 1)
        For i = 0 To UBound(dimensions)
            title = "Room " & (i + 1)
            dimensions(i) = InputBox(prompt1, title)
        Next
    End Sub

Do you know how to use classes? I would recommend created a class of "room" that has the following properties:
Length
Width
Dimension (readonly)

You can then make an array of the class and loop through the array for input and output.

Let me know if you need code.

we just learned classes last week and in this assignment we can just use an array. This is the assignment.

Write a program that uses arrays and receives the length and the width of a multi room building
and find the area needed for carpet or wood flooring. After finding the total area, give total
price suggestion for both carpet and wood flooring. Use comboBox to list price of carpets ranging
from $5 to $25 with $2 dollars increment and wood flooring from $10 to $15 range of $1.00 increment.

No classes are mentioned. I'm sorry I normally don't need this much assistance, but this one has me stumped. I have a good idea how to do the the increments using a for loop, but not how to insert them into a combo box. Our professor actually didn't show us combo boxes, but he did assign them and the book isn't much help. My main problem is coding the arrays for the multi room building prompting for length and width, from there I know how to get the area.
Hopefully I get partial credit even if it's not complete. Any help would be appreciated, thank you.

Well, if you don't want to use a class but instead only use an array, I recommend using a multidimensional array. A multidimensional array will allow you to store the lengths and widths of each room in the same array; the usage of a multidimensional array should be straight forward by looking at some code. Below is updated code showing how to use a multidimensional array:

Dim dimensions(0, 0) As Integer
    Dim rooms As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim prompt1, prompt2, title As String
        Dim i As Short
        prompt1 = "Enter the length of the room"
        prompt2 = "Enter the width of the room"
        rooms = InputBox("How many rooms?", "Create Array")

        If rooms > 0 Then ReDim dimensions(rooms - 1, 1)

        For i = 0 To UBound(dimensions)
            title = "Room " & (i + 1)
            dimensions(i, 0) = InputBox(prompt1, title)
            dimensions(i, 1) = InputBox(prompt2, title)
        Next
    End Sub

Also, here are some usful properties of the ComboBox object:

ComboBox1.Items.Add("Item 1")
        Dim selectedItemIndex As Integer
        Dim selectedItem As String
        selectedItemIndex = ComboBox1.SelectedIndex
        selectedItem = ComboBox1.SelectedItem

Let me know if you have any questions.

commented: a great help +2

thanks that helped tremendously at least I was somewhat on the right track, more like just one wheel on the track. I will now work on the combo box, thank you.

Can't figure how to populate the combobox correctly it stays blank, I think I'm completely off track. Please Help.

Public Class Form1
    Dim dimensions(0, 0) As Integer
    Dim rooms As Integer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim prompt1, prompt2, title As String
        Dim i As Short
        prompt1 = "Enter the length of the room"
        prompt2 = "Enter the width of the room"
        rooms = InputBox("How many rooms?", "Create Array")

        If rooms > 0 Then ReDim dimensions(rooms - 1, 1)
        For i = 0 To UBound(dimensions)
            title = "Room " & (i + 1)
            dimensions(i, 0) = InputBox(prompt1, title)
            dimensions(i, 1) = InputBox(prompt2, title)
        Next
    End Sub

   
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

        Dim listPrices As Integer()

        ' ComboBox1.Items.Add("Item 2")
        listPrices = New Integer() {5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25}

        Dim selectedItemIndex As Integer
        Dim selectedItem As String
        ComboBox1.Items.Add(listPrices)
        selectedItemIndex = ComboBox1.SelectedIndex
        selectedItem = ComboBox1.SelectedItem

    End Sub
End Class

There are two issue you are having:

1) You can the code to add items to the combobox within the SelectedIndexChanged event. Since there are no items in the combobox, no items can be selected and, therefore, the selected index will never change and the code is never run.

2) To populate the combobox with an array, you need to loop through array and add each item to the combobox individually.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.