home *** CD-ROM | disk | FTP | other *** search
/ An Introduction to Progr…l Basic 6.0 (4th Edition) / An Introduction to Programming using Visual Basic 6.0.iso / PROGRAMS / CH7 / 7-1-5.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-09-18  |  3.1 KB  |  102 lines

  1. VERSION 5.00
  2. Begin VB.Form frm7_1_5 
  3.    Caption         =   "World Series Winners"
  4.    ClientHeight    =   1440
  5.    ClientLeft      =   1755
  6.    ClientTop       =   2775
  7.    ClientWidth     =   6615
  8.    BeginProperty Font 
  9.       Name            =   "MS Sans Serif"
  10.       Size            =   8.25
  11.       Charset         =   0
  12.       Weight          =   700
  13.       Underline       =   0   'False
  14.       Italic          =   0   'False
  15.       Strikethrough   =   0   'False
  16.    EndProperty
  17.    LinkTopic       =   "Form1"
  18.    PaletteMode     =   1  'UseZOrder
  19.    ScaleHeight     =   1440
  20.    ScaleWidth      =   6615
  21.    Begin VB.PictureBox picSeriesWon 
  22.       Height          =   615
  23.       Left            =   120
  24.       ScaleHeight     =   555
  25.       ScaleWidth      =   6315
  26.       TabIndex        =   3
  27.       Top             =   720
  28.       Width           =   6375
  29.    End
  30.    Begin VB.CommandButton cmdDidTheyWin 
  31.       Caption         =   "Did they win?"
  32.       Default         =   -1  'True
  33.       Height          =   495
  34.       Left            =   4320
  35.       TabIndex        =   2
  36.       Top             =   120
  37.       Width           =   1695
  38.    End
  39.    Begin VB.TextBox txtName 
  40.       Height          =   285
  41.       Left            =   2520
  42.       TabIndex        =   1
  43.       Top             =   240
  44.       Width           =   1575
  45.    End
  46.    Begin VB.Label lblName 
  47.       Alignment       =   1  'Right Justify
  48.       Caption         =   "Name of baseball team:"
  49.       Height          =   255
  50.       Left            =   360
  51.       TabIndex        =   0
  52.       Top             =   240
  53.       Width           =   2055
  54.    End
  55. Attribute VB_Name = "frm7_1_5"
  56. Attribute VB_GlobalNameSpace = False
  57. Attribute VB_Creatable = False
  58. Attribute VB_PredeclaredId = True
  59. Attribute VB_Exposed = False
  60. 'Create form-level array
  61. Dim teamName() As String
  62. Dim seriesCount As Integer
  63. Private Sub cmdDidTheyWin_Click()
  64.   Dim teamToFind As String, numWon As Integer, series As Integer
  65.   'Search for World Series won by user's team
  66.   teamToFind = UCase(txtName.Text)
  67.   numWon = 0
  68.   picSeriesWon.Cls
  69.   For series = 1 To seriesCount
  70.     If UCase(teamName(series)) = teamToFind Then
  71.         numWon = numWon + 1
  72.         If numWon = 1 Then
  73.             picSeriesWon.Print "The "; teamName(series);
  74.             picSeriesWon.Print " won the following World Series: ";
  75.           Else
  76.             'Separate from previous
  77.             picSeriesWon.Print ",";
  78.             If (numWon = 5) Or (numWon = 16) Then
  79.                 'Start a new line at 5th and 16th win
  80.                 picSeriesWon.Print
  81.             End If
  82.         End If
  83.         'First world series played in 1903
  84.         picSeriesWon.Print Str(series + 1902);
  85.     End If
  86.   Next series
  87.   If numWon = 0 Then
  88.       picSeriesWon.Print "The "; teamToFind; " did not win any World Series."
  89.   End If
  90. End Sub
  91. Private Sub Form_Load()
  92.   Dim series As Integer
  93.   'Fill array with World Series winners
  94.   Open App.Path & "\WINNERS.TXT" For Input As #1
  95.   Input #1, seriesCount
  96.   ReDim teamName(1 To seriesCount) As String
  97.   For series = 1 To seriesCount
  98.     Input #1, teamName(series)
  99.   Next series
  100.   Close #1
  101. End Sub
  102.