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

  1. VERSION 5.00
  2. Begin VB.Form frm7_2_1 
  3.    Caption         =   "Ordered Search"
  4.    ClientHeight    =   1350
  5.    ClientLeft      =   1125
  6.    ClientTop       =   1470
  7.    ClientWidth     =   2505
  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     =   1350
  20.    ScaleWidth      =   2505
  21.    Begin VB.PictureBox picResult 
  22.       Height          =   255
  23.       Left            =   480
  24.       ScaleHeight     =   195
  25.       ScaleWidth      =   1515
  26.       TabIndex        =   3
  27.       Top             =   960
  28.       Width           =   1575
  29.    End
  30.    Begin VB.CommandButton cmdSearch 
  31.       Caption         =   "Look Up Name"
  32.       Default         =   -1  'True
  33.       Height          =   375
  34.       Left            =   480
  35.       TabIndex        =   2
  36.       Top             =   480
  37.       Width           =   1575
  38.    End
  39.    Begin VB.TextBox txtName 
  40.       Height          =   285
  41.       Left            =   1200
  42.       TabIndex        =   1
  43.       Top             =   120
  44.       Width           =   855
  45.    End
  46.    Begin VB.Label lblName 
  47.       Caption         =   "Name :"
  48.       Height          =   255
  49.       Left            =   480
  50.       TabIndex        =   0
  51.       Top             =   120
  52.       Width           =   615
  53.    End
  54. Attribute VB_Name = "frm7_2_1"
  55. Attribute VB_GlobalNameSpace = False
  56. Attribute VB_Creatable = False
  57. Attribute VB_PredeclaredId = True
  58. Attribute VB_Exposed = False
  59. 'Create array to hold 10 strings
  60. Dim nom(1 To 10) As String
  61. Private Sub cmdSearch_Click()
  62.   Dim n As Integer, name2Find As String
  63.   'Search for a name in an ordered list
  64.   name2Find = UCase(Trim(txtName.Text))
  65.   n = 0    'n is the subscript of the array
  66.     n = n + 1
  67.   Loop Until (nom(n) >= name2Find) Or (n = 10)
  68.   'Interpret result of search
  69.   picResult.Cls
  70.   If nom(n) = name2Find Then
  71.       picResult.Print "Found."
  72.     Else
  73.       picResult.Print "Not found."
  74.   End If
  75. End Sub
  76. Private Sub Form_Load()
  77.   'Place the names into the array
  78.   'All names must be in uppercase
  79.   nom(1) = "AL"
  80.   nom(2) = "BOB"
  81.   nom(3) = "CARL"
  82.   nom(4) = "DON"
  83.   nom(5) = "ERIC"
  84.   nom(6) = "FRED"
  85.   nom(7) = "GREG"
  86.   nom(8) = "HERB"
  87.   nom(9) = "IRA"
  88.   nom(10) = "JUDY"
  89. End Sub
  90.