home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frm7_1_2
- Caption = "Early World Series Winners"
- ClientHeight = 1260
- ClientLeft = 1395
- ClientTop = 3330
- ClientWidth = 6135
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 1260
- ScaleWidth = 6135
- Begin VB.PictureBox picWinner
- Height = 255
- Left = 120
- ScaleHeight = 195
- ScaleWidth = 5835
- TabIndex = 3
- Top = 840
- Width = 5895
- End
- Begin VB.CommandButton cmdDidTheyWin
- Caption = "Did they win?"
- Default = -1 'True
- Height = 495
- Left = 4320
- TabIndex = 2
- Top = 120
- Width = 1695
- End
- Begin VB.TextBox txtName
- Height = 285
- Left = 2280
- TabIndex = 1
- Top = 240
- Width = 1575
- End
- Begin VB.Label lblName
- Alignment = 1 'Right Justify
- Caption = "Name of baseball team:"
- Height = 255
- Left = 120
- TabIndex = 0
- Top = 240
- Width = 2055
- End
- Attribute VB_Name = "frm7_1_2"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- 'Create array for five strings
- Dim teamName(1 To 5) As String 'in (Declarations) section of (General)
- Private Sub cmdDidTheyWin_Click()
- Dim team As String, foundFlag As Boolean, n As Integer
- 'Search for an entry in a list of strings
- team = txtName.Text
- foundFlag = False
- n = 0
- n = n + 1
- If UCase(teamName(n)) = UCase(team) Then
- foundFlag = True
- End If
- Loop Until (foundFlag = True) Or (n = 5)
- 'Above line can be replaced with Loop Until (foundFlag) Or (n = 5)
- picWinner.Cls
- If foundFlag = False Then 'Can be replaced with If Not foundFlag Then
- picWinner.Print "The "; team; " did not win any";
- picWinner.Print " of the first five World Series."
- Else
- picWinner.Print "The "; teamName(n); " won World Series number"; n
- End If
- End Sub
- Private Sub Form_Load()
- 'Fill array with World Series winners
- teamName(1) = "Red Sox"
- teamName(2) = "Giants"
- teamName(3) = "White Sox"
- teamName(4) = "Cubs"
- teamName(5) = "Cubs"
- End Sub
-