I'm having trouble with this piece of code below. I tried using the Dim d and s to replace the multiplication as a friend suggested. I was unable to make this work
I need to produce the rate for each floor then come up with a total number of rooms for all floors and then produce an overall occupancy rate. Below is the output I currently get. Any help will be greatly appreciated.
I need to produce the rate for each floor then come up with a total number of rooms for all floors and then produce an overall occupancy rate. Below is the output I currently get. Any help will be greatly appreciated.
Dim intRooms As Integer Dim intTotalRoomsOccu As Integer Dim decOveralOccu As Decimal Dim intFloor As Integer = 8 Dim dbllblOveralOccu As Double Dim strDate As Date Dim Result As Double = decOveralOccu * ((intFloor * maxRoomsPerFloor) * 100) Dim d As Double = 0.01234 Dim s As String = d.ToString("p2") strDate = CDate(dtpToday.Value.ToShortDateString()) 'Insert occupancy statistics and line to list box lstData.Items.Add("Occupancy statistics for " & strDate) lstData.Items.Add("------------------------------------------------------------------") dtpToday.Enabled = True For intFloor = 1 To maxFloors strInput = InputBox("Enter number of rooms occupied?", "Floor " & intFloor) If CDbl(strInput) < 0 Or CDbl(strInput) > 30 Then MessageBox.Show("Please enter a number between 0 and 30.") Exit Sub End If lstData.Items.Add("Floor: " & intFloor & " Rooms Occupied: " & CDbl(strInput) & " Ocupancy Rate: " & decOveralOccu.ToString("n2")) '* 100) & "%" Next decOveralOccu = CDec(intTotalRoomsOccu / 240.0) lblTotalOccu.Text = intTotalRoomsOccu.ToString() lblOveralOccu.Text = Result.ToString("n2") & "%" btnComplete.Enabled = True
Last edited by a moderator: