You are on page 1of 4

Dim i As Integer Function cumul(a As Integer) As Integer Dim j As Integer Dim k As Integer k = 0 j = 1 While (j <= a) k = k + Range("h" & (1 + j)).

Value j = j + 1 Wend cumul = k End Function Function rcumul(a As Integer) As Integer Dim k As Integer Dim j As Integer k = Cells(2, 8).Value + Cells(2, 9).Value j = 1 While (j < a) k = Worksheets.Application.WorksheetFunction.Max(cumul(j + 1) + Range("i" & (j + 2)).Value, k + Range("i" & (j + 2)).Value) j = j + 1 Wend rcumul = k End Function Function propo(a As Integer) As Integer Dim k As Integer k = 0 For j = 1 To 2 * i If Range("f" & (j + 1)).Value = a Then k = k + (Range("a" & (j + 2)).Value - Range("a" & j + 1).Value) End If Next j propo = k End Function Function mclientsys() As Integer Dim k As Integer Dim s As Integer Dim r As Integer r = 0 For s = 0 To (Worksheets.Application.WorksheetFunction.Max(Range("d2:d" & ((2 * i) + 1)).Value)) k = 0 For j = 1 To 2 * i If Range("d" & (j + 1)).Value = s Then k = k + (Range("a" & (j + 2)).Value - Range("a" & j + 1).Value) End If Next j r = r + (s * k) Next s mclientsys = r End Function Function mclientatt() As Integer Dim k As Integer Dim s As Integer Dim r As Integer r = 0 For s = 1 To (Worksheets.Application.WorksheetFunction.Max(Range("d2:d" & ((2 * i) + 1)).Value)) k = 0 For j = 1 To 2 * i

If Range("d" & (j + 1)).Value = s Then k = k + (Range("a" & (j + 2)).Value - Range("a" & j + 1).Value) End If Next j r = r + ((s - 1) * k) Next s mclientatt = r End Function Function msejourclient() As Integer Dim s As Integer k = 0 For s = 1 To i k = k + (rcumul(s) - cumul(s)) Next s msejourclient = k End Function Private Sub CommandButton1_Click() Range("a:a, b:b, c:c, d:d, f:f, e:e, g:g, h:h, i:i, j:j, k:k, l:l, m:m").Clear CommandButton2.Enabled = True CommandButton3.Enabled = False CommandButton4.Enabled = False CommandButton5.Enabled = False End Sub Private Sub CommandButton2_Click() i = InputBox("entrer nombre des clients") Range("h1:i" & i + 1).Select Selection.Borders.LineStyle = xlContinuous Range("A1:f" & 2 * i + 2).Select Selection.Borders.LineStyle = xlContinuous Range("k2:m" & 2 * i + 2).Select Selection.Borders.LineStyle = xlContinuous For j = 1 To i For k = 0 To 1 Cells(1 + j, 8 + k).Value = Worksheets.Application.WorksheetFunction.RandBetween (1, 10) Next k Next j Cells(1, 1).Value = "DATE" Cells(1, 2).Value = "Ev." Cells(1, 3).Value = "N" Cells(1, 4).Value = "NL" Cells(1, 5).Value = "NQ" Cells(1, 6).Value = "S" Cells(1, 8).Value = "Arrive" Cells(1, 9).Value = "Service" Cells(2, 11).Value = "Ev" Cells(2, 12).Value = "Date" Cells(2, 13).Value = "Cli." Cells(1, 12).Value = "Calendrier" Cells(2, 1).Value = "0" Cells(2, 2).Value = "Debut" Cells(2, 4).Value = "0" Cells(2, 5).Value = "0" Cells(2, 6).Value = "0" CommandButton3.Enabled = True End Sub Private Sub CommandButton3_Click() Dim nq As Integer Dim lbr As Boolean

Dim cli As Integer Dim s As Integer Dim l As Integer cli = 1 Cells(3, 11).Value = "Arrive" Cells(3, 12).Value = Cells(2, 8).Value Cells(3, 13).Value = cli l = 2 s = 2 For s = 2 To i If cumul(s - 1) < rcumul(s) Then cli = cli + 1 Cells(2 + l, 11).Value = "Arrive" Cells(2 + l, 12).Value = cumul(s) Cells(2 + l, 13).Value = cli Cells(3 + l, 11).Value = "Dpart" Cells(3 + l, 12).Value = rcumul(s - 1) Cells(3 + l, 13).Value = cli - 1 Else Cells(2 + l, 11).Value = "Dpart" Cells(2 + l, 12).Value = rcumul(s - 1) Cells(2 + l, 13).Value = cli cli = cli + 1 Cells(3 + l, 11).Value = "Arrive" Cells(3 + l, 12).Value = cumul(s) Cells(3 + l, 13).Value = cli End If l = l + 2 Next s Cells(2 * i + 2, 11).Value = "Dpart" Cells(2 * i + 2, 12).Value = rcumul(i) Cells(2 * i + 2, 13).Value = cli CommandButton4.Enabled = True End Sub Private Sub CommandButton4_Click() Dim nl As Integer For j = 1 To 2 * i Range("a3:a" & (j + 2)).Value = Range("l3:l" & (j + 2)).Value Range("b3:b" & (j + 2)).Value = Range("k3:k" & (j + 2)).Value Range("c3:c" & (j + 2)).Value = Range("m3:m" & (j + 2)).Value Next j Range("a3:c" & ((2 * i) + 2)).Sort key1:=Range("a2"), order1:=xlAscending nl = 0 For W = 1 To 2 * i If Range("b" & (2 + W)).Value = "Arrive" Then nl = nl + 1 Cells(2 + W, 4).Value = nl Else nl = nl - 1 Cells(2 + W, 4).Value = nl End If If nl = 0 Then Cells(2 + W, 6).Value = 0 Else Cells(2 + W, 6).Value = 1 End If If nl = 1 Or nl = 0 Then Cells(2 + W, 5).Value = 0 Else Cells(2 + W, 5).Value = nl - 1

End If Next W CommandButton5.Enabled = True End Sub Private Sub CommandButton5_Click() Statistique.Label1.Caption = "La proportion ou le guichet est libre egale : " & (propo(0) / rcumul(i)) Statistique.Label2.Caption = "Nombre moyen de clients dans le system est : " & ( mclientsys / rcumul(i)) Statistique.Label3.Caption = "Nombre moyen de clients dans la fille d'attente es t : " & (mclientatt / rcumul(i)) Statistique.Label4.Caption = "Dure moyen de sjour d'un client est : " & (msejourcl ient / i) Statistique.Show End Sub

You might also like