VERSION 2.00
Begin Form Form1
Caption = "Baseball Probability"
Height = 7200
Icon = BBALLF1.FRX:0000
Left = 1050
LinkTopic = "Form1"
ScaleHeight = 6510
ScaleWidth = 7395
Top = 0
Width = 7515
Begin Frame Frame2
Caption = "Output"
Height = 3375
Left = 120
TabIndex = 9
Top = 3120
Width = 7215
Begin CommandButton CmReset
Caption = "Reset"
Height = 375
Left = 5640
TabIndex = 36
Top = 1320
Width = 1215
End
Begin CommandButton ComUpdateOutput
Caption = "Update Output"
Height = 375
Left = 3720
TabIndex = 28
Top = 1320
Width = 1575
End
Begin Label LabelMNW2
Alignment = 1 'Right Justify
Height = 255
Left = 360
TabIndex = 33
Top = 3000
Width = 1575
End
Begin Label LabelMNT2
Alignment = 1 'Right Justify
Height = 255
Left = 360
TabIndex = 32
Top = 2640
Width = 1575
End
Begin Label LabelMNW1
Alignment = 1 'Right Justify
Height = 255
Left = 360
TabIndex = 31
Top = 2280
Width = 1575
End
Begin Label LabelMNT1
Alignment = 1 'Right Justify
Height = 255
Left = 360
TabIndex = 30
Top = 1920
Width = 1575
End
Begin Label LabelPoQ
Alignment = 1 'Right Justify
Height = 255
Left = 360
TabIndex = 29
Top = 1560
Width = 1575
End
Begin Label Label1oQ
Alignment = 1 'Right Justify
Height = 255
Left = 360
TabIndex = 26
Top = 1200
Width = 1575
End
Begin Label LabelQ
Alignment = 1 'Right Justify
Height = 255
Left = 360
TabIndex = 25
Top = 840
Width = 1575
End
Begin Label LabelP
Alignment = 1 'Right Justify
Height = 255
Left = 360
TabIndex = 24
Top = 480
Width = 1575
End
Begin Label Label12
Caption = "= Magic number to win for 2nd place team"
Height = 255
Left = 2040
TabIndex = 17
Top = 3000
Width = 4935
End
Begin Label Label11
Caption = "= Magic number to tie for 2nd place team"
Height = 255
Left = 2040
TabIndex = 16
Top = 2640
Width = 4935
End
Begin Label Label10
Caption = "= Magic number to win for 1st place team"
Height = 255
Left = 2040
TabIndex = 15
Top = 2280
Width = 5055
End
Begin Label Label9
Caption = "= Magic number to tie for 1st place team"
Height = 255
Left = 2040
TabIndex = 14
Top = 1920
Width = 4935
End
Begin Label Label8
Caption = "= Odds : 1"
Height = 255
Left = 2040
TabIndex = 13
Top = 1560
Width = 1335
End
Begin Label Label7
Caption = "= 1 / Q"
Height = 255
Left = 2040
TabIndex = 12
Top = 1200
Width = 1335
End
Begin Label Label6
Caption = "= Q, Probability that 2nd place team beats 1st place team"
Height = 255
Left = 2040
TabIndex = 11
Top = 840
Width = 5055
End
Begin Label Label5
Caption = "= P, Probability that 1st place team beats 2nd place team"
Height = 255
Left = 2040
TabIndex = 10
Top = 480
Width = 5055
End
End
Begin Frame Frame1
Caption = "Input"
Height = 3015
Left = 120
TabIndex = 0
Top = 0
Width = 7215
Begin CommandButton CheckInput
Caption = "Check Input"
Height = 375
Left = 4920
TabIndex = 27
Top = 2520
Width = 1335
End
Begin TextBox txtDate
Height = 285
Left = 4920
MaxLength = 12
TabIndex = 22
Top = 1920
Width = 2055
End
Begin TextBox txtTN2
Height = 285
Left = 4920
MaxLength = 12
TabIndex = 21
Top = 1200
Width = 2055
End
Begin TextBox txtTN1
Height = 285
Left = 4920
MaxLength = 12
TabIndex = 20
Top = 480
Width = 2055
End
Begin TextBox txtGA
Height = 285
Left = 2640
MaxLength = 5
TabIndex = 5
Top = 2640
Width = 1095
End
Begin TextBox txtGE
Height = 285
Left = 2640
MaxLength = 3
TabIndex = 4
Top = 1920
Width = 1095
End
Begin TextBox txtGL2
Height = 285
Left = 2640
MaxLength = 3
TabIndex = 3
Top = 1200
Width = 1095
End
Begin TextBox txtGL1
Height = 285
Left = 2640
MaxLength = 3
TabIndex = 2
Top = 480
Width = 1095
End
Begin Label LabelGAEr
Height = 255
Left = 720
TabIndex = 35
Top = 2640
Width = 975
End
Begin Label LabelGEEr
Height = 255
Left = 720
TabIndex = 34
Top = 1920
Width = 975
End
Begin Label Label14
Caption = "Date of morning after:"
Height = 255
Left = 4920
TabIndex = 23
Top = 1680
Width = 2055
End
Begin Label Label13
Caption = "2nd Team's name:"
Height = 255
Left = 4920
TabIndex = 19
Top = 960
Width = 1575
End
Begin Label Label4
Caption = "1St Team's name:"
Height = 255
Left = 4920
TabIndex = 18
Top = 240
Width = 1575
End
Begin Label LabelGA
Caption = "Games 1st place team is ahead:"
Height = 255
Left = 480
TabIndex = 8
Top = 2400
Width = 3255
End
Begin Label LabelGE
Caption = "Games left to play each other:"
Height = 255
Left = 480
TabIndex = 7
Top = 1680
Width = 3375
End
Begin Label Label2
Caption = "Games left yo play by 2nd place team:"
Height = 255
Left = 480
TabIndex = 6
Top = 960
Width = 3255
End
Begin Label Label1
Caption = "Games left to play by 1st place team:"
Height = 255
Left = 480
TabIndex = 1
Top = 240
Width = 3255
End
End
Begin Menu File
Caption = "&File"
Begin Menu PrintSetup
Caption = "P&rint Setup"
Enabled = 0 'False
End
Begin Menu Print
Caption = "&Print..."
Shortcut = ^P
End
Begin Menu Hi
Caption = "-"
End
Begin Menu Exit
Caption = "E&xit"
End
End
Begin Menu Help
Caption = "&Help"
Begin Menu Test
Caption = "&Test"
End
Begin Menu About
Caption = "&About..."
End
End
End
Sub About_Click ()
Dim Msg, NL
NL = Chr(10) ' Define newline.
Msg = Namee$ & NL & NL
Msg = Msg & Version$ & NL & NL
Msg = Msg & Author$ & NL & NL
Msg = Msg & Address$ & NL & NL & NL & NL
Msg = Msg & Hint1$ & NL
Msg = Msg & Hint2$
MsgBox Msg ' Display message.
End Sub
Sub CheckInput_Click ()
UpdateInput
End Sub
Sub CmReset_Click ()
txtGL1.Text = ""
txtGL2.Text = ""
txtGE.Text = ""
txtGA.Text = ""
txtTN1.Text = ""
txtTN2.Text = ""
txtDate.Text = Date
LabelP = ""
LabelQ = ""
Label1oQ = ""
LabelPoQ = ""
LabelMNT1 = ""
LabelMNW1 = ""
LabelMNT2 = ""
LabelMNW2 = ""
End Sub
Sub ComUpdateOutput_Click ()
UpdateOutput
End Sub
Sub Exit_Click ()
End
End Sub
Sub Form_Load ()
Namee$ = "BBallVB - Baseball probability."
Version$ = "VisualBASIC Version 2.1a, last revised: 1994-05-28, 0600 hours"
Author$ = "Copyright (c) 1981-1994 by author: Harry J. Smith,"
Address$ = "19628 Via Monte Dr., Saratoga, CA 95070. All rights reserved."
Hint1 = "Uses a bivariate binomial distribution as a model,"
Hint2 = "and assumes each game is a 50-50 chance."
txtDate.Text = Date
End Sub
Sub Print_Click ()
Dim Msg, NL, HalfHeight, sp$
On Error GoTo ErrorHandler 'Set up error handler.
NL = Chr(10) ' Define newline.
sp$ = " "
Msg = sp$ & Namee$ & NL & sp$
Msg = Msg & Version$ & NL & sp$
Msg = Msg & Author$ & NL & sp$
Msg = Msg & Address$ & NL & NL & sp$
Msg = Msg & Hint1$ & NL & sp$
Msg = Msg & Hint2$ & NL & NL & sp$
Msg = Msg & txtDate.Text & " = Date of morning after last game" & NL & sp$
Msg = Msg & txtGL1.Text & " = Games Left to play, 1st place team ("
Msg = Msg & TN1 & ")" & NL & sp$
Msg = Msg & txtGL2.Text & " = Games Left to play, 2nd place team ("
Msg = Msg & TN2 & ")" & NL & sp$
Msg = Msg & txtGE.Text & " = Games to play each other" & NL & sp$
Msg = Msg & txtGA.Text & " = Games 1st place team is ahead. 0, 0.5, ..." & NL & NL & sp$
Msg = Msg & LabelMNT1 & " = Magic Number to tie for 1st place team" & NL & sp$
Msg = Msg & LabelMNW1 & " = Magic Number to win for 1st place team" & NL & sp$
Msg = Msg & LabelMNT2 & " = Magic Number to tie for 2nd place team" & NL & sp$
Msg = Msg & LabelMNW2 & " = Magic Number to win for 2nd place team" & NL & NL & sp$
Msg = Msg & LabelP & " = P = Probability that 1st place team beats 2nd place team" & NL & sp$
Msg = Msg & LabelQ & " = Q = Probability that 2nd place team beats 1st place team" & NL & sp$
Msg = Msg & Label1oQ & " = 1 / Q, (Odds = " & LabelPoQ & " : 1)"
HalfHeight = TextHeight(Msg) / 2 ' Calculate half height.
Printer.CurrentY = Printer.ScaleHeight / 4 - HalfHeight ' Set Y.
Printer.Print Msg
Printer.NewPage ' Send new page.
Printer.EndDoc ' Print done.
Exit Sub
ErrorHandler:
MsgBox "There was a problem printing to your printer."
Exit Sub
End Sub
Sub Test_Click ()
txtGL1.Text = "6"
txtGL2.Text = "7"
txtGE.Text = "0"
txtGA.Text = "1.5"
txtTN1.Text = "Braves"
txtTN2.Text = "Giants"
txtDate.Text = "1993-09-27"
Call UpdateOutput
End Sub
Sub txtDate_KeyPress (KeyAscii As Integer)
If (KeyAscii = 13) Then 'Keyascii 13 = Enter key
Call UpdateOutput
End If
End Sub
Sub txtGA_KeyPress (KeyAscii As Integer)
If (KeyAscii = 13) Then 'Keyascii 13 = Enter key
Call UpdateOutput
End If
End Sub
Sub txtGA_LostFocus ()
Call UpdateGA
End Sub
Sub txtGE_KeyPress (KeyAscii As Integer)
If (KeyAscii = 13) Then 'Keyascii 13 = Enter key
Call UpdateOutput
End If
End Sub
Sub txtGE_LostFocus ()
Call UpdateGE
End Sub
Sub txtGL1_KeyPress (KeyAscii As Integer)
If (KeyAscii = 13) Then 'Keyascii 13 = Enter key
Call UpdateOutput
End If
End Sub
Sub txtGL1_LostFocus ()
Call UpdateGL1
End Sub
Sub txtGL2_KeyPress (KeyAscii As Integer)
If (KeyAscii = 13) Then 'Keyascii 13 = Enter key
Call UpdateOutput
End If
End Sub
Sub txtGL2_LostFocus ()
Call UpdateGL2
End Sub
Sub txtTN1_KeyPress (KeyAscii As Integer)
If (KeyAscii = 13) Then 'Keyascii 13 = Enter key
Call UpdateOutput
End If
End Sub
Sub txtTN1_LostFocus ()
TN1 = txtTN1.Text
End Sub
Sub txtTN2_KeyPress (KeyAscii As Integer)
If (KeyAscii = 13) Then 'Keyascii 13 = Enter key
Call UpdateOutput
End If
End Sub
Sub txtTN2_LostFocus ()
TN2 = txtTN2.Text
End Sub
Sub UpdateGA ()
GA = Abs(Val(txtGA.Text))
GA2 = CLng(2 * GA) 'Round
GA = CDbl(GA2) / 2
txtGA.Text = GA
End Sub
Sub UpdateGE ()
GE = Abs(Val(txtGE.Text))
txtGE.Text = GE
End Sub
Sub UpdateGL1 ()
GL1 = Abs(Val(txtGL1.Text))
txtGL1.Text = GL1
End Sub
Sub UpdateGL2 ()
GL2 = Abs(Val(txtGL2.Text))
txtGL2.Text = GL2
End Sub
Sub UpdateInput ()
Call UpdateGL1
Call UpdateGL2
Call UpdateGA
Call UpdateGE
TN1 = txtTN1.Text
TN2 = txtTN2.Text
If GE > GL1 Or GE > GL2 Then
GEEr = True
LabelGEEr = "ERROR -->"
txtGE.ForeColor = QBColor(4) 'Red
LabelGE.ForeColor = QBColor(4)
Else
GEEr = False
LabelGEEr = ""
txtGE.ForeColor = QBColor(0) 'Black
LabelGE.ForeColor = QBColor(0)
End If
Call ExpandCase
TN1 = txtTN1.Text
TN2 = txtTN2.Text
If GAEr = True Then
LabelGAEr = "ERROR -->"
txtGA.ForeColor = QBColor(4) 'Red
LabelGA.ForeColor = QBColor(4)
Else
LabelGAEr = ""
txtGA.ForeColor = QBColor(0) 'Black
LabelGA.ForeColor = QBColor(0)
End If
End Sub
Sub UpdateOutput ()
Call UpdateInput
If GEEr Then
PEr = True
Q = 0
Else
Call ComputeProb
End If
If PEr Then
LabelP = ""
LabelQ = ""
Else
LabelP = Format(P, "0.0000")
LabelQ = Format(Q, "0.0000")
If Q = 0 Then
LabelP = "One"
LabelQ = "Zero"
Else
If LabelQ = "0.0000" Then
LabelQ = "Very Small"
LabelP = "Almost 1.0000"
End If
End If
End If
If Q <> 0 Then
If 1 / Q < 9999999999.9999 Then
Label1oQ = Format(1 / Q, "0.0000")
LabelPoQ = Format(P / Q, "0.0000")
Else
Label1oQ = "> 10^10"
LabelPoQ = "> 10^10"
End If
LabelMNT1 = MNT1
LabelMNW1 = MNW1
LabelMNT2 = MNT2
LabelMNW2 = MNW2
Else
Label1oQ = ""
LabelPoQ = ""
LabelMNT1 = ""
LabelMNW1 = ""
LabelMNT2 = ""
LabelMNW2 = ""
End If
End Sub