⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 Visual Basic 6 大学教程的代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Demonstrating the Collection Object"
   ClientHeight    =   3300
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3300
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox txtIndex 
      Height          =   285
      Left            =   2520
      TabIndex        =   7
      Top             =   945
      Width           =   2055
   End
   Begin VB.CommandButton cmdRemove 
      Caption         =   "Remove from Collection"
      Height          =   285
      Left            =   120
      TabIndex        =   4
      Top             =   1320
      Width           =   1935
   End
   Begin VB.ListBox lstOutput 
      Height          =   1620
      ItemData        =   "Form1.frx":0000
      Left            =   0
      List            =   "Form1.frx":0002
      TabIndex        =   3
      Top             =   1680
      Width           =   4695
   End
   Begin VB.CommandButton cmdAdd 
      Caption         =   "Add to Collection"
      Height          =   285
      Left            =   1373
      TabIndex        =   2
      Top             =   480
      Width           =   1935
   End
   Begin VB.TextBox txtAdd 
      Height          =   285
      Left            =   2520
      TabIndex        =   0
      Top             =   120
      Width           =   2055
   End
   Begin VB.Label lblIndex 
      Alignment       =   1  'Right Justify
      Caption         =   "Enter index of value to remove"
      Height          =   255
      Left            =   120
      TabIndex        =   6
      Top             =   960
      Width           =   2295
   End
   Begin VB.Label lblRemoved 
      Height          =   255
      Left            =   2160
      TabIndex        =   5
      Top             =   1335
      Width           =   2415
   End
   Begin VB.Line Line1 
      X1              =   0
      X2              =   4560
      Y1              =   840
      Y2              =   840
   End
   Begin VB.Label lblAdd 
      Alignment       =   1  'Right Justify
      Caption         =   "Enter value to add to Collection"
      Height          =   255
      Left            =   120
      TabIndex        =   1
      Top             =   135
      Width           =   2295
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' Fig. 21.17
' Demonstrating the Collection object
Option Explicit
Dim mMyCollection As New Collection

Private Sub cmdAdd_Click()
   Call mMyCollection.Add(txtAdd.Text)
   lblRemoved.Caption = ""
   Call Display
End Sub

Private Sub cmdRemove_Click()
   Dim index As Integer
   
   If mMyCollection.Count = 0 Then
      Call MsgBox("The Collection is empty")
      Exit Sub
   ElseIf txtIndex.Text = Null Then
      Call MsgBox("You must specify the index number to remove")
      Exit Sub
   End If
   
   index = Val(txtIndex.Text)
   
   If index < 1 Or index > mMyCollection.Count Then
      Call MsgBox("Invalid index.")
      Exit Sub
   End If
   
   lblRemoved.Caption = "Removed: " & _
      mMyCollection.Item(index)
   Call mMyCollection.Remove(index)
   Call Display
End Sub

Private Sub Display()
   Dim element As Variant
   Call lstOutput.Clear
   
   For Each element In mMyCollection
      Call lstOutput.AddItem(element)
   Next
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -