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-2.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-09-16  |  2.8 KB  |  90 lines

  1. VERSION 5.00
  2. Begin VB.Form frm7_1_2 
  3.    Caption         =   "Early World Series Winners"
  4.    ClientHeight    =   1260
  5.    ClientLeft      =   1395
  6.    ClientTop       =   3330
  7.    ClientWidth     =   6135
  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     =   1260
  20.    ScaleWidth      =   6135
  21.    Begin VB.PictureBox picWinner 
  22.       Height          =   255
  23.       Left            =   120
  24.       ScaleHeight     =   195
  25.       ScaleWidth      =   5835
  26.       TabIndex        =   3
  27.       Top             =   840
  28.       Width           =   5895
  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            =   2280
  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            =   120
  51.       TabIndex        =   0
  52.       Top             =   240
  53.       Width           =   2055
  54.    End
  55. Attribute VB_Name = "frm7_1_2"
  56. Attribute VB_GlobalNameSpace = False
  57. Attribute VB_Creatable = False
  58. Attribute VB_PredeclaredId = True
  59. Attribute VB_Exposed = False
  60. 'Create array for five strings
  61. Dim teamName(1 To 5) As String  'in (Declarations) section of (General)
  62. Private Sub cmdDidTheyWin_Click()
  63.   Dim team As String, foundFlag As Boolean, n As Integer
  64.   'Search for an entry in a list of strings
  65.   team = txtName.Text
  66.   foundFlag = False
  67.   n = 0
  68.     n = n + 1
  69.     If UCase(teamName(n)) = UCase(team) Then
  70.         foundFlag = True
  71.     End If
  72.   Loop Until (foundFlag = True) Or (n = 5)
  73.   'Above line can be replaced with Loop Until (foundFlag) Or (n = 5)
  74.   picWinner.Cls
  75.   If foundFlag = False Then   'Can be replaced with If Not foundFlag Then
  76.       picWinner.Print "The "; team; " did not win any";
  77.       picWinner.Print " of the first five World Series."
  78.     Else
  79.       picWinner.Print "The "; teamName(n); " won World Series number"; n
  80.   End If
  81. End Sub
  82. Private Sub Form_Load()
  83.   'Fill array with World Series winners
  84.   teamName(1) = "Red Sox"
  85.   teamName(2) = "Giants"
  86.   teamName(3) = "White Sox"
  87.   teamName(4) = "Cubs"
  88.   teamName(5) = "Cubs"
  89. End Sub
  90.