home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form frm7_2_1
- Caption = "Ordered Search"
- ClientHeight = 1350
- ClientLeft = 1125
- ClientTop = 1470
- ClientWidth = 2505
- 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 = 1350
- ScaleWidth = 2505
- Begin VB.PictureBox picResult
- Height = 255
- Left = 480
- ScaleHeight = 195
- ScaleWidth = 1515
- TabIndex = 3
- Top = 960
- Width = 1575
- End
- Begin VB.CommandButton cmdSearch
- Caption = "Look Up Name"
- Default = -1 'True
- Height = 375
- Left = 480
- TabIndex = 2
- Top = 480
- Width = 1575
- End
- Begin VB.TextBox txtName
- Height = 285
- Left = 1200
- TabIndex = 1
- Top = 120
- Width = 855
- End
- Begin VB.Label lblName
- Caption = "Name :"
- Height = 255
- Left = 480
- TabIndex = 0
- Top = 120
- Width = 615
- End
- Attribute VB_Name = "frm7_2_1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- 'Create array to hold 10 strings
- Dim nom(1 To 10) As String
- Private Sub cmdSearch_Click()
- Dim n As Integer, name2Find As String
- 'Search for a name in an ordered list
- name2Find = UCase(Trim(txtName.Text))
- n = 0 'n is the subscript of the array
- n = n + 1
- Loop Until (nom(n) >= name2Find) Or (n = 10)
- 'Interpret result of search
- picResult.Cls
- If nom(n) = name2Find Then
- picResult.Print "Found."
- Else
- picResult.Print "Not found."
- End If
- End Sub
- Private Sub Form_Load()
- 'Place the names into the array
- 'All names must be in uppercase
- nom(1) = "AL"
- nom(2) = "BOB"
- nom(3) = "CARL"
- nom(4) = "DON"
- nom(5) = "ERIC"
- nom(6) = "FRED"
- nom(7) = "GREG"
- nom(8) = "HERB"
- nom(9) = "IRA"
- nom(10) = "JUDY"
- End Sub
-