home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / ch_code / ch05 / keycombo / keycombo.frm (.txt) next >
Encoding:
Visual Basic Form  |  1997-02-20  |  13.4 KB  |  437 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "List Search"
  4.    ClientHeight    =   3525
  5.    ClientLeft      =   2400
  6.    ClientTop       =   1650
  7.    ClientWidth     =   6330
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3525
  10.    ScaleWidth      =   6330
  11.    Begin VB.ComboBox Combo3 
  12.       BeginProperty Font 
  13.          Name            =   "MS Sans Serif"
  14.          Size            =   9.75
  15.          Charset         =   0
  16.          Weight          =   400
  17.          Underline       =   0   'False
  18.          Italic          =   0   'False
  19.          Strikethrough   =   0   'False
  20.       EndProperty
  21.       Height          =   360
  22.       Left            =   150
  23.       Sorted          =   -1  'True
  24.       Style           =   2  'Dropdown List
  25.       TabIndex        =   3
  26.       Top             =   2235
  27.       Width           =   2535
  28.    End
  29.    Begin VB.ComboBox Combo2 
  30.       BeginProperty Font 
  31.          Name            =   "MS Sans Serif"
  32.          Size            =   9.75
  33.          Charset         =   0
  34.          Weight          =   400
  35.          Underline       =   0   'False
  36.          Italic          =   0   'False
  37.          Strikethrough   =   0   'False
  38.       EndProperty
  39.       Height          =   360
  40.       Left            =   105
  41.       Sorted          =   -1  'True
  42.       Style           =   2  'Dropdown List
  43.       TabIndex        =   8
  44.       Top             =   1440
  45.       Width           =   2535
  46.    End
  47.    Begin VB.ComboBox Combo1 
  48.       BeginProperty Font 
  49.          Name            =   "MS Sans Serif"
  50.          Size            =   9.75
  51.          Charset         =   0
  52.          Weight          =   400
  53.          Underline       =   0   'False
  54.          Italic          =   0   'False
  55.          Strikethrough   =   0   'False
  56.       EndProperty
  57.       Height          =   360
  58.       Left            =   105
  59.       Sorted          =   -1  'True
  60.       Style           =   2  'Dropdown List
  61.       TabIndex        =   9
  62.       Top             =   660
  63.       Width           =   2535
  64.    End
  65.    Begin VB.CommandButton AddButton 
  66.       Caption         =   "Add New"
  67.       BeginProperty Font 
  68.          Name            =   "MS Sans Serif"
  69.          Size            =   9.75
  70.          Charset         =   0
  71.          Weight          =   400
  72.          Underline       =   0   'False
  73.          Italic          =   0   'False
  74.          Strikethrough   =   0   'False
  75.       EndProperty
  76.       Height          =   495
  77.       Left            =   4890
  78.       TabIndex        =   0
  79.       Top             =   2835
  80.       Width           =   1215
  81.    End
  82.    Begin VB.CommandButton CancelButton 
  83.       Caption         =   "Cancel"
  84.       BeginProperty Font 
  85.          Name            =   "MS Sans Serif"
  86.          Size            =   9.75
  87.          Charset         =   0
  88.          Weight          =   400
  89.          Underline       =   0   'False
  90.          Italic          =   0   'False
  91.          Strikethrough   =   0   'False
  92.       EndProperty
  93.       Height          =   495
  94.       Left            =   2970
  95.       TabIndex        =   2
  96.       Top             =   2835
  97.       Width           =   1215
  98.    End
  99.    Begin VB.CommandButton OKButton 
  100.       Caption         =   "OK"
  101.       BeginProperty Font 
  102.          Name            =   "MS Sans Serif"
  103.          Size            =   9.75
  104.          Charset         =   0
  105.          Weight          =   400
  106.          Underline       =   0   'False
  107.          Italic          =   0   'False
  108.          Strikethrough   =   0   'False
  109.       EndProperty
  110.       Height          =   495
  111.       Left            =   4890
  112.       TabIndex        =   1
  113.       Top             =   2835
  114.       Width           =   1215
  115.    End
  116.    Begin VB.TextBox Text1 
  117.       BeginProperty Font 
  118.          Name            =   "MS Sans Serif"
  119.          Size            =   9.75
  120.          Charset         =   0
  121.          Weight          =   400
  122.          Underline       =   0   'False
  123.          Italic          =   0   'False
  124.          Strikethrough   =   0   'False
  125.       EndProperty
  126.       Height          =   330
  127.       Left            =   2985
  128.       TabIndex        =   7
  129.       Top             =   555
  130.       Width           =   1455
  131.    End
  132.    Begin VB.TextBox Text2 
  133.       BeginProperty Font 
  134.          Name            =   "MS Sans Serif"
  135.          Size            =   9.75
  136.          Charset         =   0
  137.          Weight          =   400
  138.          Underline       =   0   'False
  139.          Italic          =   0   'False
  140.          Strikethrough   =   0   'False
  141.       EndProperty
  142.       Height          =   315
  143.       Left            =   4665
  144.       Locked          =   -1  'True
  145.       TabIndex        =   6
  146.       Top             =   555
  147.       Width           =   1455
  148.    End
  149.    Begin VB.TextBox Text3 
  150.       BeginProperty Font 
  151.          Name            =   "MS Sans Serif"
  152.          Size            =   9.75
  153.          Charset         =   0
  154.          Weight          =   400
  155.          Underline       =   0   'False
  156.          Italic          =   0   'False
  157.          Strikethrough   =   0   'False
  158.       EndProperty
  159.       Height          =   315
  160.       Left            =   2985
  161.       Locked          =   -1  'True
  162.       TabIndex        =   5
  163.       Top             =   1320
  164.       Width           =   3135
  165.    End
  166.    Begin VB.TextBox Text4 
  167.       BeginProperty Font 
  168.          Name            =   "MS Sans Serif"
  169.          Size            =   9.75
  170.          Charset         =   0
  171.          Weight          =   400
  172.          Underline       =   0   'False
  173.          Italic          =   0   'False
  174.          Strikethrough   =   0   'False
  175.       EndProperty
  176.       Height          =   315
  177.       Left            =   2985
  178.       Locked          =   -1  'True
  179.       TabIndex        =   4
  180.       Top             =   1995
  181.       Width           =   3135
  182.    End
  183.    Begin VB.Frame Frame1 
  184.       Height          =   2700
  185.       Left            =   0
  186.       TabIndex        =   17
  187.       Top             =   225
  188.       Width           =   2775
  189.       Begin VB.Label Label10 
  190.          Caption         =   "Search by VISA #"
  191.          Height          =   225
  192.          Left            =   180
  193.          TabIndex        =   20
  194.          Top             =   1770
  195.          Width           =   1395
  196.       End
  197.       Begin VB.Label Label9 
  198.          Caption         =   "Search by AMEX #"
  199.          Height          =   255
  200.          Left            =   180
  201.          TabIndex        =   19
  202.          Top             =   945
  203.          Width           =   1545
  204.       End
  205.       Begin VB.Label Label8 
  206.          Caption         =   "Search By SSN"
  207.          Height          =   225
  208.          Left            =   180
  209.          TabIndex        =   18
  210.          Top             =   165
  211.          Width           =   1620
  212.       End
  213.    End
  214.    Begin VB.Label Label7 
  215.       Caption         =   "VISA"
  216.       BeginProperty Font 
  217.          Name            =   "MS Sans Serif"
  218.          Size            =   9.75
  219.          Charset         =   0
  220.          Weight          =   400
  221.          Underline       =   0   'False
  222.          Italic          =   0   'False
  223.          Strikethrough   =   0   'False
  224.       EndProperty
  225.       Height          =   225
  226.       Left            =   3015
  227.       TabIndex        =   16
  228.       Top             =   1740
  229.       Width           =   1890
  230.    End
  231.    Begin VB.Label Label6 
  232.       Caption         =   "American Express"
  233.       BeginProperty Font 
  234.          Name            =   "MS Sans Serif"
  235.          Size            =   9.75
  236.          Charset         =   0
  237.          Weight          =   400
  238.          Underline       =   0   'False
  239.          Italic          =   0   'False
  240.          Strikethrough   =   0   'False
  241.       EndProperty
  242.       Height          =   225
  243.       Left            =   3015
  244.       TabIndex        =   15
  245.       Top             =   1020
  246.       Width           =   1665
  247.    End
  248.    Begin VB.Label Label5 
  249.       Caption         =   "SSN"
  250.       BeginProperty Font 
  251.          Name            =   "MS Sans Serif"
  252.          Size            =   9.75
  253.          Charset         =   0
  254.          Weight          =   400
  255.          Underline       =   0   'False
  256.          Italic          =   0   'False
  257.          Strikethrough   =   0   'False
  258.       EndProperty
  259.       Height          =   225
  260.       Left            =   4665
  261.       TabIndex        =   14
  262.       Top             =   330
  263.       Width           =   1125
  264.    End
  265.    Begin VB.Label Label4 
  266.       Caption         =   "Name"
  267.       BeginProperty Font 
  268.          Name            =   "MS Sans Serif"
  269.          Size            =   9.75
  270.          Charset         =   0
  271.          Weight          =   400
  272.          Underline       =   0   'False
  273.          Italic          =   0   'False
  274.          Strikethrough   =   0   'False
  275.       EndProperty
  276.       Height          =   240
  277.       Left            =   2970
  278.       TabIndex        =   13
  279.       Top             =   300
  280.       Width           =   1215
  281.    End
  282.    Begin VB.Label Label3 
  283.       Caption         =   "VISA"
  284.       BeginProperty Font 
  285.          Name            =   "MS Sans Serif"
  286.          Size            =   9.75
  287.          Charset         =   0
  288.          Weight          =   400
  289.          Underline       =   0   'False
  290.          Italic          =   0   'False
  291.          Strikethrough   =   0   'False
  292.       EndProperty
  293.       Height          =   195
  294.       Left            =   135
  295.       TabIndex        =   12
  296.       Top             =   1770
  297.       Width           =   1515
  298.    End
  299.    Begin VB.Label Label2 
  300.       Caption         =   "American Express"
  301.       BeginProperty Font 
  302.          Name            =   "MS Sans Serif"
  303.          Size            =   9.75
  304.          Charset         =   0
  305.          Weight          =   400
  306.          Underline       =   0   'False
  307.          Italic          =   0   'False
  308.          Strikethrough   =   0   'False
  309.       EndProperty
  310.       Height          =   255
  311.       Left            =   120
  312.       TabIndex        =   11
  313.       Top             =   1035
  314.       Width           =   1905
  315.    End
  316.    Begin VB.Label Label1 
  317.       Caption         =   "SSN"
  318.       BeginProperty Font 
  319.          Name            =   "MS Sans Serif"
  320.          Size            =   9.75
  321.          Charset         =   0
  322.          Weight          =   400
  323.          Underline       =   0   'False
  324.          Italic          =   0   'False
  325.          Strikethrough   =   0   'False
  326.       EndProperty
  327.       Height          =   270
  328.       Left            =   120
  329.       TabIndex        =   10
  330.       Top             =   285
  331.       Width           =   1590
  332.    End
  333. Attribute VB_Name = "Form1"
  334. Attribute VB_GlobalNameSpace = False
  335. Attribute VB_Creatable = False
  336. Attribute VB_PredeclaredId = True
  337. Attribute VB_Exposed = False
  338. Dim DataArray(999, 3) As String
  339. Dim ArrayIndex As Integer
  340. Sub ClearFields()
  341.     Text1.Text = ""
  342.     Text2.Text = ""
  343.     Text2.Locked = False
  344.     Text3.Text = ""
  345.     Text3.Locked = False
  346.     Text4.Text = ""
  347.     Text4.Locked = False
  348.     AddButton.Visible = False
  349.     OKButton.Visible = True
  350.     CancelButton.Visible = True
  351. End Sub
  352. Sub ShowButtons()
  353.     OKButton.Visible = False
  354.     CancelButton.Visible = False
  355.     AddButton.Visible = True
  356.     Text2.Locked = True
  357.     Text3.Locked = True
  358.     Text4.Locked = True
  359. End Sub
  360. Private Sub AddButton_Click()
  361.     ClearFields
  362.     Text1.SetFocus
  363. End Sub
  364. Private Sub CancelButton_Click()
  365.     ShowButtons
  366.     Combo1_Click
  367. End Sub
  368. Private Sub Combo1_Click()
  369.     If Combo1.ListIndex < 0 Then
  370.         Text1.Text = ""
  371.         Text2.Text = ""
  372.         Text3.Text = ""
  373.         Text4.Text = ""
  374.         Exit Sub
  375.     End If
  376.     ItemIndex = Combo1.ItemData(Combo1.ListIndex)
  377.     Text1.Text = DataArray(ItemIndex, 0)
  378.     Text2.Text = DataArray(ItemIndex, 1)
  379.     Text3.Text = DataArray(ItemIndex, 2)
  380.     Text4.Text = DataArray(ItemIndex, 3)
  381. End Sub
  382. Private Sub Combo2_Click()
  383.     If Combo2.ListIndex < 0 Then
  384.         Text1.Text = ""
  385.         Text2.Text = ""
  386.         Text3.Text = ""
  387.         Text4.Text = ""
  388.         Exit Sub
  389.     End If
  390.     ItemIndex = Combo2.ItemData(Combo2.ListIndex)
  391.     Text1.Text = DataArray(ItemIndex, 0)
  392.     Text2.Text = DataArray(ItemIndex, 1)
  393.     Text3.Text = DataArray(ItemIndex, 2)
  394.     Text4.Text = DataArray(ItemIndex, 3)
  395. End Sub
  396. Private Sub Combo3_Click()
  397.     If Combo3.ListIndex < 0 Then
  398.         Text1.Text = ""
  399.         Text2.Text = ""
  400.         Text3.Text = ""
  401.         Text4.Text = ""
  402.         Exit Sub
  403.     End If
  404.     ItemIndex = Combo3.ItemData(Combo3.ListIndex)
  405.     Text1.Text = DataArray(ItemIndex, 0)
  406.     Text2.Text = DataArray(ItemIndex, 1)
  407.     Text3.Text = DataArray(ItemIndex, 2)
  408.     Text4.Text = DataArray(ItemIndex, 3)
  409. End Sub
  410. Private Sub OKButton_Click()
  411.     Key = Trim(Text1.Text)
  412.     If Key = "" Then
  413.         MsgBox "Key field must be non-mepty"
  414.         Exit Sub
  415.     End If
  416.     ArrayIndex = ArrayIndex + 1
  417.     Combo1.AddItem Text2.Text
  418.     Combo1.ItemData(Combo1.NewIndex) = ArrayIndex
  419.     If Text3.Text <> "" Then
  420.         Combo2.AddItem Text3.Text
  421.         Combo2.ItemData(Combo2.NewIndex) = ArrayIndex
  422.     End If
  423.     If Text4.Text <> "" Then
  424.         Combo3.AddItem Text4.Text
  425.         Combo3.ItemData(Combo3.NewIndex) = ArrayIndex
  426.     End If
  427.     DataArray(ArrayIndex, 0) = Text1.Text
  428.     DataArray(ArrayIndex, 1) = Text2.Text
  429.     DataArray(ArrayIndex, 2) = Text3.Text
  430.     DataArray(ArrayIndex, 3) = Text4.Text
  431.     Combo1.ListIndex = Combo1.NewIndex
  432.     Combo2.ListIndex = Combo2.NewIndex
  433.     Combo3.ListIndex = Combo3.NewIndex
  434.     ShowButtons
  435.     Text1.SetFocus
  436. End Sub
  437.