fb:porticula NoPaste
Hotel-Manager Vorratsverwaltung [VB]
Uploader: | Jojo |
Datum/Zeit: | 02.07.2007 18:25:26 |
Dim lVorrat(0 To 3) As Double
Dim Platz As Long
Dim i As Integer
lVorrat(0) = Vorrat.Vegetarisch
lVorrat(1) = Vorrat.Fleisch
lVorrat(2) = Vorrat.Milchprodukte
lVorrat(3) = Vorrat.Trinken
Platz = 75000 + Anzahl.Kühlraum * 100000
For i = 0 To 3
Platz = Platz - lVorrat(i)
Next i
If Platz = 0 Then Exit Sub
Dim lMax As Long, lMin As Long, iBelegt As Integer
lMax = 0
lMin = Platz
For i = 0 To 3
If lVorrat(i) > lMax Then lMax = lVorrat(i)
If lVorrat(i) < lMin Then lMin = lVorrat(i)
Next i
Dim Gesamt As Long
iBelegt = 0
For i = 0 To 3
lVorrat(i) = 1 - lVorrat(i) / lMax
lVorrat(i) = lVorrat(i) * Platz
Gesamt = Gesamt + Int(lVorrat(i))
If lVorrat(i) > 0 Then iBelegt = iBelegt + 1
Next i
Dim Abzug As Long, Hinzu As Long
If Gesamt > Platz Then
Abzug = (Gesamt - Platz) / iBelegt
For i = 0 To 3
If lVorrat(i) > 0 Then lVorrat(i) = lVorrat(i) - Abzug
Next i
ElseIf Gesamt < Platz Then
Hinzu = (Platz - Gesamt) / 4
For i = 0 To 3
lVorrat(i) = lVorrat(i) + Hinzu
Next i
End If
Dim Kosten As Double
Kosten = 0
iBelegt = 0
For i = 0 To 3
Kosten = Kosten + lVorrat(i)
If lVorrat(i) > 0 Then iBelegt = iBelegt + 1
Next
Kosten = Int(Kosten / 4)
If Kosten > Hotel.Geld Then
Abzug = (Kosten - Hotel.Geld) / iBelegt
Abzug = Abzug * 4
For i = 0 To 3
If lVorrat(i) > 0 Then lVorrat(i) = lVorrat(i) - Abzug
Next
End If
For i = 0 To 3
ScrollBar(i).Value = Int(lVorrat(i))
Next i
Exit Sub