Help Stuck area of a multiroom building
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
bpacheco1227
Junior Poster in Training
58 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
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.
bpacheco1227
Junior Poster in Training
58 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
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.
bpacheco1227
Junior Poster in Training
58 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0
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
bpacheco1227
Junior Poster in Training
58 posts since Jul 2007
Reputation Points: 10
Solved Threads: 0