hello,

i have a project in which i have to make a program that will calculate the total waiting time and the average waiting time of a maximum of 5 processes (or also known as process management/ process queue)

this is my second project.. the first one i had was first come first served.. for those of you guyz who undergone a course about operating systems, im sure you would understand what im saying..

the code below was my code on the first come first served process queue:

Code:
Option Explicit

Dim inputs(5) As Integer
Dim ans As Integer
Dim a As Integer





Private Sub btn_enter_Click()
Dim wid As Integer

On Error GoTo errorhandler
 If ((txt_proc.Text < 0) Or (txt_proc.Text Like 0)) Then
    MsgBox "Enter numbers greater than 0", vbCritical, "Error"

 Else
   
   If (a < cmb_proc.Text) Then
        inputs(a) = txt_proc.Text
        List1.AddItem ("input " & a + 1 & ": " & inputs(a))
        wid = inputs(a) * 100
        
        If (a Like 0) Then
            txt_1.Visible = True    'put if statements in each txt
            txt_1.Width = wid
            txt_1.Text = inputs(a)
       ElseIf (a Like 1) Then
            txt_2.Visible = True
            txt_2.Left = 240 + txt_1.Width
            txt_2.Width = wid
            txt_2.Text = inputs(a)
       ElseIf (a Like 2) Then
            txt_3.Visible = True
            txt_3.Left = txt_2.Left + txt_2.Width
            txt_3.Width = wid
            txt_3.Text = inputs(a)
       ElseIf (a Like 3) Then
            txt_4.Visible = True
            txt_4.Left = txt_3.Left + txt_3.Width
            txt_4.Width = wid
            txt_4.Text = inputs(a)
       ElseIf (a Like 4) Then
            txt_5.Visible = True
            txt_5.Left = txt_4.Left + txt_4.Width
            txt_5.Width = wid
            txt_5.Text = inputs(a)
       ElseIf (a Like 5) Then
            txt_6.Visible = True
            txt_6.Left = txt_5.Left + txt_5.Width
            txt_6.Width = wid
            txt_6.Text = inputs(a)
       End If
        
         a = a + 1
     If (a Like cmb_proc.Text) Then
           btn_ok.Enabled = True
           txt_proc.Enabled = False
            btn_enter.Enabled = False
            cmb_proc.Enabled = True
            calc
            cmb_proc.Text = ""
       End If
    End If
    
    txt_proc.Text = ""
    
    End If
    Exit Sub
    
errorhandler:
    If (Err.Number = 6) Then
    MsgBox "overflow", vbInformation, "overflow"
    End If
   
   
End Sub
    

Private Sub btn_ok_Click()

If (cmb_proc.Text Like "") Then
    MsgBox "Please choose number of processes.", vbCritical, "Error"
Else
    a = 0
    btn_ok.Enabled = False
    cmb_proc.Enabled = False
    txt_proc.Enabled = True
    btn_enter.Enabled = True
    Form1.Refresh
    txt_1.Visible = False
    txt_2.Visible = False
    txt_3.Visible = False
    txt_4.Visible = False
    txt_5.Visible = False
    txt_6.Visible = False
    List1.Clear
End If
End Sub






Public Sub calc()
   Dim total As Integer
   Dim ave As Integer
   Dim bars(5) As Object
   Dim p As Integer
   Dim p1 As Integer
     
    
    If (cmb_proc.Text Like 1) Then
        total = inputs(0)
   Else
     While (p < cmb_proc.Text - 1)
        For p1 = p + 1 To cmb_proc.Text - 1
            total = total + inputs(p)
        Next p1
        p = p + 1
    Wend
    
   End If
   
   ave = total / cmb_proc.Text
    MsgBox "Total waiting time is: " & total
    MsgBox "Average waiting time is: " & ave
    txt_1.Visible = True
End Sub
this following algorithm was my algorithm for first come first served:
Code:
Public Sub calc()
   Dim total As Integer
   Dim ave As Integer
   Dim bars(5) As Object
   Dim p As Integer
   Dim p1 As Integer
     
    
    If (cmb_proc.Text Like 1) Then
        total = inputs(0)
   Else
     While (p < cmb_proc.Text - 1)
        For p1 = p + 1 To cmb_proc.Text - 1
            total = total + inputs(p)
        Next p1
        p = p + 1
    Wend
    
   End If
   
   ave = total / cmb_proc.Text
    MsgBox "Total waiting time is: " & total
    MsgBox "Average waiting time is: " & ave
    txt_1.Visible = True
End Sub

it also has some sort of progress bar or status bar that would provide the user some visualization on the length of each process he enters..



if theres anyone who can help me with this, please post the algorithm on how to come up with the total waiting time and average waiting time for time quantum/ round robin....