home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / horser1a / form1.frm (.txt) next >
Encoding:
Visual Basic Form  |  1999-09-19  |  8.4 KB  |  263 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BackColor       =   &H00FFFFFF&
  4.    Caption         =   "Horse Racing!"
  5.    ClientHeight    =   6315
  6.    ClientLeft      =   3030
  7.    ClientTop       =   2355
  8.    ClientWidth     =   12525
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   6315
  11.    ScaleWidth      =   12525
  12.    Begin VB.CommandButton cmdReset 
  13.       Caption         =   "&Reset"
  14.       BeginProperty Font 
  15.          Name            =   "MS Sans Serif"
  16.          Size            =   12
  17.          Charset         =   0
  18.          Weight          =   400
  19.          Underline       =   0   'False
  20.          Italic          =   0   'False
  21.          Strikethrough   =   0   'False
  22.       EndProperty
  23.       Height          =   495
  24.       Left            =   10680
  25.       TabIndex        =   7
  26.       Top             =   5640
  27.       Width           =   1455
  28.    End
  29.    Begin VB.OptionButton optSlow 
  30.       BackColor       =   &H00FFFFFF&
  31.       Caption         =   "Slow Horse"
  32.       Height          =   255
  33.       Left            =   2520
  34.       TabIndex        =   6
  35.       Top             =   5760
  36.       Width           =   1215
  37.    End
  38.    Begin VB.OptionButton optFast 
  39.       BackColor       =   &H00FFFFFF&
  40.       Caption         =   "Fast Horse"
  41.       Height          =   255
  42.       Left            =   2520
  43.       TabIndex        =   5
  44.       Top             =   5400
  45.       Value           =   -1  'True
  46.       Width           =   1095
  47.    End
  48.    Begin VB.TextBox txtBet 
  49.       Height          =   285
  50.       Left            =   5040
  51.       TabIndex        =   1
  52.       Text            =   "50"
  53.       Top             =   5520
  54.       Width           =   855
  55.    End
  56.    Begin VB.CommandButton Command1 
  57.       Caption         =   "&Start Race"
  58.       BeginProperty Font 
  59.          Name            =   "MS Sans Serif"
  60.          Size            =   12
  61.          Charset         =   0
  62.          Weight          =   400
  63.          Underline       =   0   'False
  64.          Italic          =   0   'False
  65.          Strikethrough   =   0   'False
  66.       EndProperty
  67.       Height          =   495
  68.       Left            =   10680
  69.       TabIndex        =   0
  70.       Top             =   5040
  71.       Width           =   1455
  72.    End
  73.    Begin VB.Label lblFunds 
  74.       BackStyle       =   0  'Transparent
  75.       Caption         =   "$100"
  76.       BeginProperty Font 
  77.          Name            =   "MS Sans Serif"
  78.          Size            =   9.75
  79.          Charset         =   0
  80.          Weight          =   400
  81.          Underline       =   0   'False
  82.          Italic          =   0   'False
  83.          Strikethrough   =   0   'False
  84.       EndProperty
  85.       Height          =   495
  86.       Left            =   1320
  87.       TabIndex        =   4
  88.       Top             =   5520
  89.       Width           =   1215
  90.    End
  91.    Begin VB.Label Label2 
  92.       AutoSize        =   -1  'True
  93.       BackStyle       =   0  'Transparent
  94.       Caption         =   "Total Funds:"
  95.       BeginProperty Font 
  96.          Name            =   "MS Sans Serif"
  97.          Size            =   9.75
  98.          Charset         =   0
  99.          Weight          =   400
  100.          Underline       =   0   'False
  101.          Italic          =   0   'False
  102.          Strikethrough   =   0   'False
  103.       EndProperty
  104.       Height          =   240
  105.       Left            =   120
  106.       TabIndex        =   3
  107.       Top             =   5520
  108.       Width           =   1110
  109.    End
  110.    Begin VB.Label Label1 
  111.       AutoSize        =   -1  'True
  112.       BackStyle       =   0  'Transparent
  113.       Caption         =   "Place Bet:"
  114.       BeginProperty Font 
  115.          Name            =   "MS Sans Serif"
  116.          Size            =   9.75
  117.          Charset         =   0
  118.          Weight          =   400
  119.          Underline       =   0   'False
  120.          Italic          =   0   'False
  121.          Strikethrough   =   0   'False
  122.       EndProperty
  123.       Height          =   240
  124.       Left            =   3960
  125.       TabIndex        =   2
  126.       Top             =   5520
  127.       Width           =   915
  128.    End
  129.    Begin VB.Image ImgSHorse 
  130.       Height          =   1335
  131.       Left            =   10200
  132.       Picture         =   "Form1.frx":0000
  133.       Top             =   2640
  134.       Width           =   1920
  135.    End
  136.    Begin VB.Image imgFHorse 
  137.       Height          =   1560
  138.       Left            =   10200
  139.       Picture         =   "Form1.frx":0A52
  140.       Top             =   480
  141.       Width           =   1920
  142.    End
  143.    Begin VB.Menu mnuFile 
  144.       Caption         =   "&File"
  145.       Begin VB.Menu mnuStart 
  146.          Caption         =   "&Start Race"
  147.       End
  148.       Begin VB.Menu mnuExit 
  149.          Caption         =   "E&xit"
  150.       End
  151.    End
  152. Attribute VB_Name = "Form1"
  153. Attribute VB_GlobalNameSpace = False
  154. Attribute VB_Creatable = False
  155. Attribute VB_PredeclaredId = True
  156. Attribute VB_Exposed = False
  157. Dim intMoney As Integer
  158. Private Sub cmdReset_Click()
  159.     Command1.Enabled = True
  160.     intMoney = 100
  161.     txtBet.Text = "50"
  162.     lblFunds.Caption = intMoney
  163. End Sub
  164. Private Sub Command1_Click()
  165.     Dim intRnd1 As Integer, intRnd2 As Integer
  166.        
  167.         If Val(txtBet.Text) > intMoney Then
  168.             MsgBox "You don't have that much money!"
  169.         
  170.         Else
  171.             Randomize
  172.             Do While imgFHorse.Left > 0 And ImgSHorse.Left > 0      'do while neither is at the left
  173.                 intRnd1 = Int((10 - 1 + 1) * Rnd + 1)
  174.                 intRnd2 = Int((10 - 1 + 1) * Rnd + 1)
  175.                 imgFHorse.Left = imgFHorse.Left - intRnd1           'subtract rand # from left
  176.                 ImgSHorse.Left = ImgSHorse.Left - intRnd2
  177.             Loop
  178.             If imgFHorse.Left <= 0 And ImgSHorse.Left <= 0 Then
  179.                 MsgBox "It's a Tie"
  180.             Else
  181.                 If imgFHorse.Left <= 0 Then
  182.                     MsgBox "Fast Horse Wins!"
  183.                     If optFast.Value = True Then
  184.                         intMoney = intMoney + Val(txtBet.Text)
  185.                     Else
  186.                         intMoney = intMoney - Val(txtBet.Text)
  187.                     End If
  188.                 
  189.                 Else
  190.                     MsgBox "Slow Horse Wins!"
  191.                     If optSlow.Value = True Then
  192.                         intMoney = intMoney + Val(txtBet.Text)
  193.                     Else
  194.                         intMoney = intMoney - Val(txtBet.Text)
  195.                     End If
  196.                 End If
  197.             End If
  198.         End If
  199.             lblFunds.Caption = intMoney
  200.             imgFHorse.Left = 10200
  201.             ImgSHorse.Left = 10200
  202.     If intMoney = 0 Then
  203.         MsgBox "You Lose!"
  204.         Command1.Enabled = False
  205.     End If
  206.             
  207.         
  208.         
  209.         
  210.         
  211. End Sub
  212. Private Sub Command2_Click()
  213. End Sub
  214. Private Sub Form_Load()
  215.     intMoney = 100
  216. End Sub
  217. Private Sub mnuExit_Click()
  218.     End
  219. End Sub
  220. Private Sub mnuStart_Click()
  221. Dim intRnd1 As Integer, intRnd2 As Integer
  222.        
  223.         If Val(txtBet.Text) > intMoney Then
  224.             MsgBox "You don't have that much money!"
  225.         
  226.         Else
  227.             Randomize
  228.             Do While imgFHorse.Left > 0 And ImgSHorse.Left > 0      'do while neither is at the left
  229.                 intRnd1 = Int((10 - 1 + 1) * Rnd + 1)
  230.                 intRnd2 = Int((10 - 1 + 1) * Rnd + 1)
  231.                 imgFHorse.Left = imgFHorse.Left - intRnd1           'subtract rand # from left
  232.                 ImgSHorse.Left = ImgSHorse.Left - intRnd2
  233.             Loop
  234.             If imgFHorse.Left <= 0 And ImgSHorse.Left <= 0 Then
  235.                 MsgBox "It's a Tie"
  236.             Else
  237.                 If imgFHorse.Left <= 0 Then
  238.                     MsgBox "Fast Horse Wins!"
  239.                     If optFast.Value = True Then
  240.                         intMoney = intMoney + Val(txtBet.Text)
  241.                     Else
  242.                         intMoney = intMoney - Val(txtBet.Text)
  243.                     End If
  244.                 
  245.                 Else
  246.                     MsgBox "Slow Horse Wins!"
  247.                     If optSlow.Value = True Then
  248.                         intMoney = intMoney + Val(txtBet.Text)
  249.                     Else
  250.                         intMoney = intMoney - Val(txtBet.Text)
  251.                     End If
  252.                 End If
  253.             End If
  254.         End If
  255.             lblFunds.Caption = intMoney
  256.             imgFHorse.Left = 10200
  257.             ImgSHorse.Left = 10200
  258.     If intMoney = 0 Then
  259.         MsgBox "You Lose!"
  260.         Command1.Enabled = False
  261.     End If
  262. End Sub
  263.