⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmtrade.frm

📁 股票交易模拟器 A Stock Exchange simulator to show timers and randon number generators work together. A c
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmTrade 
   BackColor       =   &H00C0C000&
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Stock Trading Simulator"
   ClientHeight    =   6765
   ClientLeft      =   1890
   ClientTop       =   1245
   ClientWidth     =   7590
   Icon            =   "frmTrade.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   Moveable        =   0   'False
   ScaleHeight     =   6765
   ScaleWidth      =   7590
   Begin VB.Timer tmrEndOfGame 
      Interval        =   65000
      Left            =   6720
      Top             =   5880
   End
   Begin VB.Timer tmrClock 
      Interval        =   950
      Left            =   360
      Top             =   5760
   End
   Begin VB.Timer tmrBid 
      Interval        =   3000
      Left            =   6840
      Top             =   1440
   End
   Begin VB.Timer tmrAsk 
      Interval        =   2500
      Left            =   240
      Top             =   1320
   End
   Begin VB.CommandButton cmdSell 
      BackColor       =   &H000040C0&
      Caption         =   "&Sell"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   5880
      Style           =   1  'Graphical
      TabIndex        =   14
      Top             =   4440
      Width           =   1335
   End
   Begin VB.CommandButton cmdBuy 
      BackColor       =   &H0000C000&
      Caption         =   "&Buy"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   360
      Style           =   1  'Graphical
      TabIndex        =   13
      Top             =   4440
      Width           =   1335
   End
   Begin VB.Label lblTimeLeft 
      BackColor       =   &H00C0C000&
      Caption         =   "Time Left: 65"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   360
      TabIndex        =   12
      Top             =   6360
      Width           =   1575
   End
   Begin VB.Label lblInventory 
      BackColor       =   &H00FFFFC0&
      BorderStyle     =   1  'Fixed Single
      Height          =   375
      Left            =   3360
      TabIndex        =   11
      Top             =   5400
      Width           =   1215
   End
   Begin VB.Label Label6 
      BackColor       =   &H00C0C000&
      Caption         =   "Inventory"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3000
      TabIndex        =   10
      Top             =   4920
      Width           =   1575
   End
   Begin VB.Label lblCash 
      BackColor       =   &H00FFFFC0&
      BorderStyle     =   1  'Fixed Single
      Height          =   375
      Left            =   3360
      TabIndex        =   9
      Top             =   4080
      Width           =   1215
   End
   Begin VB.Label Label5 
      BackColor       =   &H00C0C000&
      Caption         =   "Cash"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3000
      TabIndex        =   8
      Top             =   3600
      Width           =   1575
   End
   Begin VB.Line Line1 
      BorderWidth     =   3
      X1              =   120
      X2              =   7440
      Y1              =   3240
      Y2              =   3240
   End
   Begin VB.Label lblBidUnits 
      BackColor       =   &H00FFFFC0&
      BorderStyle     =   1  'Fixed Single
      Height          =   375
      Left            =   5160
      TabIndex        =   7
      Top             =   2520
      Width           =   1215
   End
   Begin VB.Label Label4 
      BackColor       =   &H00C0C000&
      Caption         =   "Num Units"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   5040
      TabIndex        =   6
      Top             =   2040
      Width           =   1575
   End
   Begin VB.Label lblAskUnits 
      BackColor       =   &H00FFFFC0&
      BorderStyle     =   1  'Fixed Single
      Height          =   375
      Left            =   1080
      TabIndex        =   5
      Top             =   2520
      Width           =   1215
   End
   Begin VB.Label Label3 
      BackColor       =   &H00C0C000&
      Caption         =   "Num Units"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   960
      TabIndex        =   4
      Top             =   2040
      Width           =   1575
   End
   Begin VB.Label lblBidPrice 
      BackColor       =   &H00FFFFC0&
      BorderStyle     =   1  'Fixed Single
      Height          =   375
      Left            =   5160
      TabIndex        =   3
      Top             =   960
      Width           =   1215
   End
   Begin VB.Label Label2 
      BackColor       =   &H00C0C000&
      Caption         =   "Bidding Price"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4920
      TabIndex        =   2
      Top             =   480
      Width           =   1695
   End
   Begin VB.Label lblAskPrice 
      BackColor       =   &H00FFFFC0&
      BorderStyle     =   1  'Fixed Single
      Height          =   375
      Left            =   1080
      TabIndex        =   1
      Top             =   960
      Width           =   1215
   End
   Begin VB.Label Label1 
      BackColor       =   &H00C0C000&
      Caption         =   "Asking Price"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   960
      TabIndex        =   0
      Top             =   480
      Width           =   1575
   End
End
Attribute VB_Name = "frmTrade"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Const LowQuote = 5
Const HighQuote = 15
Const TransactionFee = 10
Const UnitShortPenalty = 10
Const GameLength = 65
Dim AskPrice As Currency
Dim AskUnits As Currency
Dim BidPrice As Currency
Dim BidUnits As Currency
Dim Cash As Currency
Dim Inventory As Integer
Dim TimeRemaining As Integer




Private Sub cmdBuy_Click()
    
    Cash = Cash - TransactionFee - AskPrice * AskUnits
    lblCash.Caption = Format$(Cash, "currency")
    Inventory = Inventory + AskUnits
    lblInventory.Caption = Inventory
    AskPrice = 0
    AskUnits = 0
    lblAskPrice.Caption = ""
    lblAskUnits.Caption = ""
    cmdBuy.Enabled = False
    
End Sub



Private Sub cmdSell_Click()
    
    Cash = Cash - TransactionFee + BidPrice * BidUnits
    lblCash.Caption = Format$(Cash, "currency")
    Inventory = Inventory - BidUnits
    lblInventory.Caption = Inventory
    BidPrice = 0
    BidUnits = 0
    lblBidPrice.Caption = ""
    lblBidUnits.Caption = ""
    cmdSell.Enabled = False
    
End Sub

Private Sub Form_Load()
    
    Randomize
    TimeRemaining = GameLength
End Sub

Private Sub tmrAsk_Timer()
    
    AskPrice = LowQuote + (HighQuote - LowQuote) * Rnd()
    lblAskPrice.Caption = AskPrice
    AskUnits = LowQuote + Int((1 + HighQuote - LowQuote) * Rnd())
    lblAskUnits.Caption = AskUnits
    cmdBuy.Enabled = True
    
End Sub


Private Sub tmrBid_Timer()
    
    BidPrice = LowQuote + (HighQuote - LowQuote) * Rnd()
    lblBidPrice.Caption = BidPrice
    BidUnits = LowQuote + Int((1 + HighQuote - LowQuote) * Rnd())
    lblBidUnits.Caption = BidUnits
    cmdSell.Enabled = True
    
End Sub




Private Sub tmrClock_Timer()
    
    TimeRemaining = TimeRemaining - 1
    lblTimeLeft.Caption = "Time Left: " & TimeRemaining
    
End Sub



Private Sub tmrEndOfGame_Timer()
    
    Cash = Cash - IIf(Inventory >= 0, 0, UnitShortPenalty * Abs(Inventory))
    MsgBox Format$(Cash, "currency"), vbInformation, "Ending Cash Position"
    tmrEndOfGame.Enabled = False
    End
    
End Sub

⌨️ 快捷键说明

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