www.pudn.com > vb生产者-消费者问题.rar > Form1.frm


VERSION 5.00 
Begin VB.Form Form1  
   BackColor       =   &H00FFFFFF& 
   Caption         =   "Form1" 
   ClientHeight    =   5295 
   ClientLeft      =   3450 
   ClientTop       =   1920 
   ClientWidth     =   5925 
   BeginProperty Font  
      Name            =   "宋体" 
      Size            =   15 
      Charset         =   134 
      Weight          =   700 
      Underline       =   0   'False 
      Italic          =   0   'False 
      Strikethrough   =   0   'False 
   EndProperty 
   LinkTopic       =   "Form1" 
   Picture         =   "Form1.frx":0000 
   ScaleHeight     =   5295 
   ScaleWidth      =   5925 
   Begin VB.CommandButton Command2  
      Caption         =   "消费者" 
      BeginProperty Font  
         Name            =   "宋体" 
         Size            =   9 
         Charset         =   134 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   495 
      Left            =   3360 
      TabIndex        =   1 
      Top             =   4680 
      Width           =   1335 
   End 
   Begin VB.CommandButton Command1  
      Caption         =   "成产者" 
      BeginProperty Font  
         Name            =   "宋体" 
         Size            =   9 
         Charset         =   134 
         Weight          =   400 
         Underline       =   0   'False 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   495 
      Left            =   360 
      TabIndex        =   0 
      Top             =   4680 
      Width           =   1215 
   End 
   Begin VB.Label Label2  
      BackStyle       =   0  'Transparent 
      Caption         =   "生产者--消费者" 
      BeginProperty Font  
         Name            =   "宋体" 
         Size            =   21.75 
         Charset         =   134 
         Weight          =   700 
         Underline       =   -1  'True 
         Italic          =   0   'False 
         Strikethrough   =   0   'False 
      EndProperty 
      Height          =   1215 
      Left            =   1200 
      TabIndex        =   3 
      Top             =   600 
      Width           =   3735 
   End 
   Begin VB.Label Label1  
      BackStyle       =   0  'Transparent 
      Height          =   1335 
      Left            =   480 
      TabIndex        =   2 
      Top             =   3360 
      Width           =   4215 
   End 
   Begin VB.Image Image3  
      Height          =   855 
      Left            =   3120 
      Picture         =   "Form1.frx":76F2 
      Stretch         =   -1  'True 
      Top             =   2400 
      Width           =   855 
   End 
   Begin VB.Image Image2  
      Height          =   855 
      Left            =   2280 
      Picture         =   "Form1.frx":8BB2 
      Stretch         =   -1  'True 
      Top             =   2400 
      Width           =   855 
   End 
   Begin VB.Image Image1  
      Enabled         =   0   'False 
      Height          =   855 
      Left            =   1440 
      Picture         =   "Form1.frx":A072 
      Stretch         =   -1  'True 
      Top             =   2400 
      Width           =   855 
   End 
End 
Attribute VB_Name = "Form1" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Dim counter As Integer 
 
Private Sub Command1_Click() 
If counter < 4 Then 
counter = counter + 1 
End If 
If counter > 3 Then 
Label1.Caption = "空间已满,不能再容纳汉堡了 " 
End If 
If counter = 1 Then 
Image1.Visible = True 
 End If 
 If counter = 2 Then 
Image2.Visible = True 
End If 
If counter = 3 Then 
Image3.Visible = True 
End If 
 
End Sub 
 
Private Sub Command2_Click() 
If counter < 1 Then 
Label1.Caption = "没有汉堡可吃,我们好饿,请快点生产" 
End If 
If counter = 4 Then 
counter = counter - 1 
End If 
If counter = 1 Then 
Image1.Visible = False 
 End If 
 If counter = 2 Then 
Image2.Visible = False 
End If 
If counter = 3 Then 
Image3.Visible = False 
End If 
If counter > 0 Then 
counter = counter - 1 
End If 
End Sub 
 
Private Sub Form_Load() 
Image1.Visible = False 
Image2.Visible = False 
Image3.Visible = False 
counter = 0 
End Sub