frm_sjf.frm

来自「计算机操作系统之短作业优先调度算法交互式演示」· FRM 代码 · 共 407 行

FRM
407
字号
VERSION 5.00
Begin VB.Form frm_SJF 
   Caption         =   "短作业优先"
   ClientHeight    =   8580
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   12705
   LinkTopic       =   "Form1"
   ScaleHeight     =   8580
   ScaleWidth      =   12705
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame1 
      BackColor       =   &H008080FF&
      Caption         =   "短作业优先算法"
      Height          =   4935
      Left            =   360
      TabIndex        =   2
      Top             =   720
      Width           =   12015
      Begin VB.TextBox Text1 
         Alignment       =   2  'Center
         Height          =   600
         Left            =   1920
         TabIndex        =   8
         Text            =   "7.7"
         Top             =   1320
         Width           =   1300
      End
      Begin VB.TextBox Text2 
         Alignment       =   2  'Center
         Height          =   600
         Left            =   1920
         TabIndex        =   7
         Text            =   "6.3"
         Top             =   2400
         Width           =   1300
      End
      Begin VB.TextBox Text3 
         Alignment       =   2  'Center
         Height          =   600
         Left            =   1920
         TabIndex        =   6
         Text            =   "5.5"
         Top             =   3480
         Width           =   1300
      End
      Begin VB.TextBox Text5 
         Alignment       =   2  'Center
         Height          =   600
         Left            =   3840
         TabIndex        =   5
         Text            =   "1.3"
         Top             =   1320
         Width           =   1300
      End
      Begin VB.TextBox Text6 
         Alignment       =   2  'Center
         Height          =   600
         Left            =   3840
         TabIndex        =   4
         Text            =   "1.7"
         Top             =   2400
         Width           =   1300
      End
      Begin VB.TextBox Text7 
         Alignment       =   2  'Center
         Height          =   600
         Left            =   3840
         TabIndex        =   3
         Text            =   "2.3"
         Top             =   3480
         Width           =   1300
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         Caption         =   "作业1"
         Height          =   600
         Left            =   120
         TabIndex        =   25
         Top             =   1320
         Width           =   1305
      End
      Begin VB.Label Label2 
         Alignment       =   2  'Center
         Caption         =   "提交时间"
         Height          =   615
         Left            =   1920
         TabIndex        =   24
         Top             =   480
         Width           =   1335
      End
      Begin VB.Label Label3 
         Alignment       =   2  'Center
         Caption         =   "运行时间"
         Height          =   615
         Left            =   3720
         TabIndex        =   23
         Top             =   480
         Width           =   1455
      End
      Begin VB.Label Label4 
         Alignment       =   2  'Center
         Caption         =   "开始时间"
         Height          =   615
         Left            =   5760
         TabIndex        =   22
         Top             =   480
         Width           =   1455
      End
      Begin VB.Label Label5 
         Alignment       =   2  'Center
         Caption         =   "结束时间"
         Height          =   615
         Left            =   7800
         TabIndex        =   21
         Top             =   480
         Width           =   1335
      End
      Begin VB.Label Label6 
         Alignment       =   2  'Center
         BackColor       =   &H0080FF80&
         Height          =   600
         Left            =   9840
         TabIndex        =   20
         Top             =   1320
         Width           =   1305
      End
      Begin VB.Label Label7 
         Alignment       =   2  'Center
         BackColor       =   &H0080FF80&
         Height          =   600
         Left            =   9840
         TabIndex        =   19
         Top             =   2400
         Width           =   1305
      End
      Begin VB.Label Label8 
         Alignment       =   2  'Center
         BackColor       =   &H0080FF80&
         Height          =   600
         Left            =   9840
         TabIndex        =   18
         Top             =   3480
         Width           =   1305
      End
      Begin VB.Label Label9 
         Alignment       =   2  'Center
         BackColor       =   &H0080FF80&
         Height          =   600
         Left            =   5760
         TabIndex        =   17
         Top             =   1320
         Width           =   1305
      End
      Begin VB.Label Label10 
         Alignment       =   2  'Center
         BackColor       =   &H0080FF80&
         Height          =   600
         Left            =   7800
         TabIndex        =   16
         Top             =   1320
         Width           =   1305
      End
      Begin VB.Label Label11 
         Alignment       =   2  'Center
         BackColor       =   &H0080FF80&
         Height          =   600
         Left            =   5760
         TabIndex        =   15
         Top             =   2400
         Width           =   1305
      End
      Begin VB.Label Label12 
         Alignment       =   2  'Center
         BackColor       =   &H0080FF80&
         Height          =   600
         Left            =   7800
         TabIndex        =   14
         Top             =   2400
         Width           =   1305
      End
      Begin VB.Label Label13 
         Alignment       =   2  'Center
         BackColor       =   &H0080FF80&
         Height          =   600
         Left            =   5760
         TabIndex        =   13
         Top             =   3480
         Width           =   1305
      End
      Begin VB.Label Label14 
         Alignment       =   2  'Center
         BackColor       =   &H0080FF80&
         Height          =   600
         Left            =   7800
         TabIndex        =   12
         Top             =   3480
         Width           =   1305
      End
      Begin VB.Label Label15 
         Alignment       =   2  'Center
         Caption         =   "作业2"
         Height          =   600
         Left            =   120
         TabIndex        =   11
         Top             =   2400
         Width           =   1305
      End
      Begin VB.Label Label16 
         Alignment       =   2  'Center
         Caption         =   "作业3"
         Height          =   600
         Left            =   120
         TabIndex        =   10
         Top             =   3600
         Width           =   1305
      End
      Begin VB.Label Label17 
         Alignment       =   2  'Center
         Caption         =   "CPU处理顺序"
         Height          =   615
         Left            =   9840
         TabIndex        =   9
         Top             =   480
         Width           =   1215
      End
   End
   Begin VB.CommandButton Command2 
      Caption         =   "返回"
      Height          =   615
      Left            =   7200
      TabIndex        =   1
      Top             =   6360
      Width           =   2295
   End
   Begin VB.CommandButton Command1 
      Caption         =   "提交"
      Height          =   615
      Left            =   2760
      TabIndex        =   0
      Top             =   6360
      Width           =   2175
   End
End
Attribute VB_Name = "frm_SJF"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
Dim a1 As Double
Dim a2 As Double
Dim a3 As Double
Dim a4 As Double
Dim a5 As Double
Dim a6 As Double


a1 = CDbl(Text1.Text)
a2 = CDbl(Text2.Text)
a3 = CDbl(Text3.Text)

a4 = CDbl(Text5.Text)
a5 = CDbl(Text6.Text)
a6 = CDbl(Text7.Text)

If a1 < a2 And a1 < a3 Then
    MsgBox "作业1首先到达,得到CPU"
    Label6.Caption = "第一个进入"
    Label9.Caption = Text1.Text
    Label10.Caption = Str(a4 + Label9.Caption)
        If Label10.Caption >= CDbl(Text2.Text) And Label10.Caption >= CDbl(Text3.Text) Then
            MsgBox "作业2  和作业3  就绪"
            If a5 < a6 Then
                MsgBox "作业2 比 作业3 短 , 首先把CPU给作业2"
                Label11.Caption = Label10.Caption
                Label12.Caption = Str(a5 + Label11.Caption)
                Label7.Caption = "第二个进入"
                Label13.Caption = Label12.Caption
                Label14.Caption = Str(a6 + Label13.Caption)
                Label8.Caption = "第三个进入"
            Else
                MsgBox "作业3 比 作业2 短 , 首先把CPU给作业3"
                Label13.Caption = Label10.Caption
                Label14.Caption = Str(a6 + Label13.Caption)
                Label8.Caption = "第二个进入"
                Label11.Caption = Label14.Caption
                Label12.Caption = Str(a5 + Label11.Caption)
                Label7.Caption = "第三个进入"
            End If
        Else
            If a2 < a3 Then
                MsgBox "作业2提交时间到  进入,得到CPU"
                Label11.Caption = Text2.Text
                Label12.Caption = Str(a5 + Label11.Caption)
                Label7.Caption = "第二个进入"
                Label13.Caption = Label12.Caption
                Label14.Caption = Str(a6 + Label13.Caption)
                Label8.Caption = "第三个进入"
            Else
                MsgBox "作业3提交时间到  进入,得到CPU"
                Label13.Caption = Text3.Text
                Label14.Caption = Str(a6 + Label13.Caption)
                Label8.Caption = "第二个进入"
                Label11.Caption = Label14.Caption
                Label12.Caption = Str(a5 + Label11)
                Label7.Caption = "第三个进入"
            End If
        End If
    
ElseIf a2 < a1 And a2 < a3 Then
    MsgBox "作业2首先到达,得到CPU"
    Label7.Caption = "第一个进入"
    Label11.Caption = Text2.Text
    Label12.Caption = Str(a5 + Label11.Caption)
        If Label12.Caption >= CDbl(Text1.Text) And Label10.Caption >= CDbl(Text3.Text) Then
            MsgBox "作业1  和作业3  就绪"
            If a4 < a6 Then
                MsgBox "作业1 比 作业3 短 , 首先把CPU给作业1"
                Label9.Caption = Label12.Caption
                Label10.Caption = Str(a4 + Label9.Caption)
                Label6.Caption = "第二个进入"
                Label13.Caption = Label10.Caption
                Label14.Caption = Str(a6 + Label13.Caption)
                Label8.Caption = "第三个进入"
            Else
                MsgBox "作业3 比 作业1 短 , 首先把CPU给作业3"
                Label13.Caption = Label12.Caption
                Label14.Caption = Str(a6 + Label13.Caption)
                Label8.Caption = "第二个进入"
                Label9.Caption = Label14.Caption
                Label10.Caption = Str(a4 + Label9.Caption)
                Label6.Caption = "第三个进入"
            End If
        Else
            If a1 < a3 Then
                MsgBox "作业1提交时间到  进入,得到CPU"
                Label9.Caption = Text1.Text
                Label10.Caption = Str(a4 + Label9.Caption)
                Label6.Caption = "第二个进入"
                Label13.Caption = Label10.Caption
                Label14.Caption = Str(a6 + Label13.Caption)
                Label8.Caption = "第三个进入"
            Else
                MsgBox "作业3提交时间到  进入,得到CPU"
                Label13.Caption = Text3.Text
                Label14.Caption = Str(a6 + Label13.Caption)
                Label8.Caption = "第二个进入"
                Label9.Caption = Label14.Caption
                Label10.Caption = Str(a4 + Label9)
                Label6.Caption = "第三个进入"
            End If
        End If

ElseIf a3 < a1 And a3 < a2 Then
    MsgBox "作业3首先到达,得到CPU"
    Label8.Caption = "第一个进入"
    Label13.Caption = Str(Text3.Text)
    Label14.Caption = Str(CDbl(Label13.Caption) + a6)
        If Label14.Caption >= CDbl(Text2.Text) And Label14.Caption >= CDbl(Text1.Text) Then
            MsgBox "作业1  和作业2  就绪"
            If a4 < a5 Then
                MsgBox "作业1 比 作业2 短 , 首先把CPU给作业1"
                Label9.Caption = Label14.Caption
                Label10.Caption = Str(a4 + Label9.Caption)
                Label6.Caption = "第二个进入"
                Label11.Caption = Label10.Caption
                Label12.Caption = Str(a5 + Label11.Caption)
                Label7.Caption = "第三个进入"
            Else
                MsgBox "作业2 比 作业1 短 , 首先把CPU给作业2"
                Label11.Caption = Label14.Caption
                Label12.Caption = Str(a5 + Label11.Caption)
                Label7.Caption = "第二个进入"
                Label9.Caption = Label12.Caption
                Label10.Caption = Str(a4 + Label9.Caption)
                Label6.Caption = "第三个进入"
            End If
        Else
            If a1 < a2 Then
                MsgBox "作业1提交时间到  进入,得到CPU"
                Label9.Caption = Text1.Text
                Label10.Caption = Str(a4 + Label9.Caption)
                Label6.Caption = "第二个进入"
                Label11.Caption = Label10.Caption
                Label12.Caption = Str(a5 + Label11.Caption)
                Label7.Caption = "第三个进入"
            Else
                MsgBox "作业2提交时间到  进入,得到CPU"
                Label11.Caption = Text2.Text
                Label12.Caption = Str(a5 + Label11.Caption)
                Label7.Caption = "第二个进入"
                Label9.Caption = Label12.Caption
                Label10.Caption = Str(a4 + Label9)
                Label6.Caption = "第三个进入"
            End If
        End If
End If
End Sub

Private Sub Command2_Click()
Unload Me
End Sub


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?