home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / ch_code / ch05 / listdemo / listdemo.frm (.txt) next >
Encoding:
Visual Basic Form  |  1998-07-03  |  8.1 KB  |  269 lines

  1. VERSION 5.00
  2. Begin VB.Form ListsForm 
  3.    Caption         =   "ListDemo"
  4.    ClientHeight    =   4830
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   6600
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   4830
  10.    ScaleWidth      =   6600
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton Command8 
  13.       Caption         =   "Clear List"
  14.       BeginProperty Font 
  15.          Name            =   "Verdana"
  16.          Size            =   9.75
  17.          Charset         =   0
  18.          Weight          =   400
  19.          Underline       =   0   'False
  20.          Italic          =   0   'False
  21.          Strikethrough   =   0   'False
  22.       EndProperty
  23.       Height          =   435
  24.       Left            =   3975
  25.       TabIndex        =   9
  26.       Top             =   4170
  27.       Width           =   2460
  28.    End
  29.    Begin VB.CommandButton Command7 
  30.       Caption         =   "Clear List"
  31.       BeginProperty Font 
  32.          Name            =   "Verdana"
  33.          Size            =   9.75
  34.          Charset         =   0
  35.          Weight          =   400
  36.          Underline       =   0   'False
  37.          Italic          =   0   'False
  38.          Strikethrough   =   0   'False
  39.       EndProperty
  40.       Height          =   435
  41.       Left            =   135
  42.       TabIndex        =   8
  43.       Top             =   4140
  44.       Width           =   2460
  45.    End
  46.    Begin VB.CommandButton Command6 
  47.       Caption         =   "Add New Element"
  48.       BeginProperty Font 
  49.          Name            =   "Verdana"
  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          =   435
  58.       Left            =   3975
  59.       TabIndex        =   7
  60.       Top             =   3600
  61.       Width           =   2460
  62.    End
  63.    Begin VB.CommandButton Command5 
  64.       Caption         =   "Add New Element"
  65.       BeginProperty Font 
  66.          Name            =   "Verdana"
  67.          Size            =   9.75
  68.          Charset         =   0
  69.          Weight          =   400
  70.          Underline       =   0   'False
  71.          Italic          =   0   'False
  72.          Strikethrough   =   0   'False
  73.       EndProperty
  74.       Height          =   435
  75.       Left            =   135
  76.       TabIndex        =   6
  77.       Top             =   3585
  78.       Width           =   2460
  79.    End
  80.    Begin VB.CommandButton Command4 
  81.       Caption         =   "Remove Selected Items"
  82.       BeginProperty Font 
  83.          Name            =   "Verdana"
  84.          Size            =   9.75
  85.          Charset         =   0
  86.          Weight          =   400
  87.          Underline       =   0   'False
  88.          Italic          =   0   'False
  89.          Strikethrough   =   0   'False
  90.       EndProperty
  91.       Height          =   435
  92.       Left            =   3960
  93.       TabIndex        =   5
  94.       Top             =   3045
  95.       Width           =   2475
  96.    End
  97.    Begin VB.CommandButton Command3 
  98.       Caption         =   "Remove Selected Item"
  99.       BeginProperty Font 
  100.          Name            =   "Verdana"
  101.          Size            =   9.75
  102.          Charset         =   0
  103.          Weight          =   400
  104.          Underline       =   0   'False
  105.          Italic          =   0   'False
  106.          Strikethrough   =   0   'False
  107.       EndProperty
  108.       Height          =   435
  109.       Left            =   135
  110.       TabIndex        =   4
  111.       Top             =   3030
  112.       Width           =   2460
  113.    End
  114.    Begin VB.CommandButton Command2 
  115.       Caption         =   "<<"
  116.       BeginProperty Font 
  117.          Name            =   "Tahoma"
  118.          Size            =   12
  119.          Charset         =   0
  120.          Weight          =   700
  121.          Underline       =   0   'False
  122.          Italic          =   0   'False
  123.          Strikethrough   =   0   'False
  124.       EndProperty
  125.       Height          =   510
  126.       Left            =   2910
  127.       TabIndex        =   3
  128.       Top             =   1980
  129.       Width           =   705
  130.    End
  131.    Begin VB.CommandButton Command1 
  132.       Caption         =   ">>"
  133.       BeginProperty Font 
  134.          Name            =   "Tahoma"
  135.          Size            =   12
  136.          Charset         =   0
  137.          Weight          =   700
  138.          Underline       =   0   'False
  139.          Italic          =   0   'False
  140.          Strikethrough   =   0   'False
  141.       EndProperty
  142.       Height          =   510
  143.       Left            =   2910
  144.       TabIndex        =   2
  145.       Top             =   990
  146.       Width           =   705
  147.    End
  148.    Begin VB.ListBox List2 
  149.       Height          =   1815
  150.       Left            =   3930
  151.       MultiSelect     =   2  'Extended
  152.       Sorted          =   -1  'True
  153.       TabIndex        =   1
  154.       Top             =   810
  155.       Width           =   2490
  156.    End
  157.    Begin VB.ListBox List1 
  158.       Height          =   1815
  159.       Left            =   120
  160.       TabIndex        =   0
  161.       Top             =   810
  162.       Width           =   2490
  163.    End
  164.    Begin VB.Label Label2 
  165.       Alignment       =   2  'Center
  166.       Caption         =   "Sorted List"
  167.       BeginProperty Font 
  168.          Name            =   "Verdana"
  169.          Size            =   11.25
  170.          Charset         =   0
  171.          Weight          =   700
  172.          Underline       =   0   'False
  173.          Italic          =   0   'False
  174.          Strikethrough   =   0   'False
  175.       EndProperty
  176.       Height          =   360
  177.       Left            =   3945
  178.       TabIndex        =   11
  179.       Top             =   225
  180.       Width           =   2415
  181.    End
  182.    Begin VB.Label Label1 
  183.       Alignment       =   2  'Center
  184.       Caption         =   "Unsorted List"
  185.       BeginProperty Font 
  186.          Name            =   "Verdana"
  187.          Size            =   11.25
  188.          Charset         =   0
  189.          Weight          =   700
  190.          Underline       =   0   'False
  191.          Italic          =   0   'False
  192.          Strikethrough   =   0   'False
  193.       EndProperty
  194.       Height          =   360
  195.       Left            =   120
  196.       TabIndex        =   10
  197.       Top             =   225
  198.       Width           =   2415
  199.    End
  200. Attribute VB_Name = "ListsForm"
  201. Attribute VB_GlobalNameSpace = False
  202. Attribute VB_Creatable = False
  203. Attribute VB_PredeclaredId = True
  204. Attribute VB_Exposed = False
  205. Option Explicit
  206. Private Sub Command1_Click()
  207.     If List1.ListIndex >= 0 Then
  208.         List2.AddItem List1.Text
  209.         List1.RemoveItem List1.ListIndex
  210.     End If
  211. End Sub
  212. Private Sub Command10_Click()
  213.     List2.Sorted = True
  214. End Sub
  215. Private Sub Command2_Click()
  216. Dim i As Integer
  217.     If List2.SelCount = 1 Then
  218.         List1.AddItem List2.Text
  219.         List2.RemoveItem List2.ListIndex
  220.     ElseIf List2.SelCount > 1 Then
  221.         For i = List2.ListCount - 1 To 0 Step -1
  222.             If List2.Selected(i) Then
  223.                 List1.AddItem List2.List(i)
  224.                 List2.RemoveItem i
  225.             End If
  226.         Next
  227.     End If
  228. End Sub
  229. Private Sub Command3_Click()
  230.     If List1.ListIndex > 0 Then
  231.         List1.RemoveItem List1.ListIndex
  232.     End If
  233. End Sub
  234. Private Sub Command4_Click()
  235. Dim i As Integer
  236.     If List2.SelCount = 1 Then
  237.         List2.RemoveItem List2.ListIndex
  238.     ElseIf List2.ListCount > 1 Then
  239.         For i = List2.ListCount - 1 To 0 Step -1
  240.             If List2.Selected(i) Then
  241.                 List2.RemoveItem i
  242.             End If
  243.         Next
  244.     End If
  245. End Sub
  246. Private Sub Command5_Click()
  247. Dim listItem As String
  248.     listItem = InputBox("Enter item to add to the list")
  249.     If Trim(listItem) <> "" Then
  250.         List1.AddItem listItem
  251.     End If
  252. End Sub
  253. Private Sub Command6_Click()
  254. Dim listItem As String
  255.     listItem = InputBox("Enter item to add to the list")
  256.     If Trim(listItem) <> "" Then
  257.         List2.AddItem listItem
  258.     End If
  259. End Sub
  260. Private Sub Command7_Click()
  261.     List1.Clear
  262. End Sub
  263. Private Sub Command8_Click()
  264.     List2.Clear
  265. End Sub
  266. Private Sub Command9_Click()
  267.     List1.Sorted = True
  268. End Sub
  269.