home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / c_arr1a / frmc_arr.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-19  |  3.9 KB  |  138 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "cArray Example"
  4.    ClientHeight    =   3195
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3195
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton cmdSet 
  13.       Caption         =   "Set"
  14.       Height          =   495
  15.       Left            =   3360
  16.       TabIndex        =   6
  17.       Top             =   2280
  18.       Width           =   1215
  19.    End
  20.    Begin VB.CommandButton cmdGet 
  21.       Caption         =   "Get"
  22.       Height          =   495
  23.       Left            =   3360
  24.       TabIndex        =   5
  25.       Top             =   1680
  26.       Width           =   1215
  27.    End
  28.    Begin VB.CommandButton cmdDown 
  29.       Caption         =   "Down"
  30.       Height          =   495
  31.       Left            =   3240
  32.       TabIndex        =   4
  33.       Top             =   840
  34.       Width           =   975
  35.    End
  36.    Begin VB.CommandButton cmdUp 
  37.       Caption         =   "Up"
  38.       Height          =   495
  39.       Left            =   3240
  40.       TabIndex        =   3
  41.       Top             =   240
  42.       Width           =   975
  43.    End
  44.    Begin VB.CommandButton cmdRemove 
  45.       Caption         =   "Remove"
  46.       Height          =   375
  47.       Left            =   1680
  48.       TabIndex        =   2
  49.       Top             =   2280
  50.       Width           =   1215
  51.    End
  52.    Begin VB.CommandButton cmdAdd 
  53.       Caption         =   "Add"
  54.       Height          =   375
  55.       Left            =   120
  56.       TabIndex        =   1
  57.       Top             =   2280
  58.       Width           =   1335
  59.    End
  60.    Begin VB.ListBox lstArray 
  61.       Height          =   1815
  62.       Left            =   120
  63.       TabIndex        =   0
  64.       Top             =   120
  65.       Width           =   3015
  66.    End
  67. Attribute VB_Name = "Form1"
  68. Attribute VB_GlobalNameSpace = False
  69. Attribute VB_Creatable = False
  70. Attribute VB_PredeclaredId = True
  71. Attribute VB_Exposed = False
  72. 'I didn't go to alot of trouble with this form, because
  73. 'I knew that you guys will be smart enough to figure
  74. 'out how the class work. Good luck.
  75. Dim myA As c_Array
  76. Private Sub cmdAdd_Click()
  77.     itemValue = InputBox("Enter Text")
  78.     Key = InputBox("Enter Key")
  79.     myA.Add itemValue, Key
  80.     Update
  81. End Sub
  82. Private Sub cmdRemove_Click()
  83.     If MsgBox("Yes: Enter Key      No: Enter Index", vbYesNo) = vbYes Then
  84.         Key = InputBox("Enter key:", "Remove")
  85.         myA.Remove , Key
  86.       Else
  87.         Index = InputBox("Enter Index:", "Remove")
  88.         myA.Remove Index
  89.     End If
  90.     Update
  91. End Sub
  92. Private Sub cmdUp_Click()
  93.     If lstArray.ListIndex = -1 Then
  94.         Beep
  95.         Exit Sub
  96.     End If
  97.     myA.MoveUp lstArray.ListIndex + 1
  98.     Update
  99. End Sub
  100. Private Sub cmdDown_Click()
  101.     If lstArray.ListIndex = -1 Then
  102.         Beep
  103.         Exit Sub
  104.     End If
  105.     myA.MoveDown lstArray.ListIndex + 1
  106.     Update
  107. End Sub
  108. Private Sub cmdGet_Click()
  109.     If MsgBox("Yes: Enter Key      No: Enter Index", vbYesNo) = vbYes Then
  110.         Key = InputBox("Enter Key:")
  111.         MsgBox myA.Itemget(, Key)
  112.       Else
  113.         Index = InputBox("Enter Index:")
  114.         MsgBox myA.Itemget(Index)
  115.     End If
  116. End Sub
  117. Private Sub cmdSet_Click()
  118.     If MsgBox("Yes: Enter Key     No: Enter Index", vbYesNo, "Set") = vbYes Then
  119.         Key = InputBox("Enter Key:", "Set")
  120.         newVal = InputBox("Enter new value:", "Set")
  121.         myA.Itemset newVal, , Key
  122.       Else
  123.         Index = InputBox("Enter Index", "Set")
  124.         newVal = InputBox("Enter new value:", "Set")
  125.         myA.Itemset newVal, Index
  126.     End If
  127.     Update
  128. End Sub
  129. Private Sub Form_Load()
  130.     Set myA = New c_Array
  131. End Sub
  132. Function Update()
  133.     lstArray.Clear
  134.     For i = 1 To myA.Count
  135.         lstArray.AddItem myA.Itemget(i)
  136.     Next
  137. End Function
  138.