home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Programmer'…arterly (Limited Edition) / Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso / code / ch19code / textboxe.frm < prev    next >
Text File  |  1995-08-14  |  5KB  |  170 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   2172
  5.    ClientLeft      =   2592
  6.    ClientTop       =   1512
  7.    ClientWidth     =   3636
  8.    BeginProperty Font 
  9.       name            =   "MS Sans Serif"
  10.       charset         =   0
  11.       weight          =   400
  12.       size            =   7.8
  13.       underline       =   0   'False
  14.       italic          =   0   'False
  15.       strikethrough   =   0   'False
  16.    EndProperty
  17.    Height          =   2496
  18.    Left            =   2544
  19.    LinkTopic       =   "Form1"
  20.    ScaleHeight     =   2172
  21.    ScaleWidth      =   3636
  22.    Top             =   1236
  23.    Width           =   3732
  24.    Begin VB.CommandButton cmdClear 
  25.       Caption         =   "Clear All"
  26.       BeginProperty Font 
  27.          name            =   "MS Sans Serif"
  28.          charset         =   0
  29.          weight          =   400
  30.          size            =   7.8
  31.          underline       =   0   'False
  32.          italic          =   0   'False
  33.          strikethrough   =   0   'False
  34.       EndProperty
  35.       Height          =   375
  36.       Left            =   720
  37.       TabIndex        =   4
  38.       Top             =   1680
  39.       Width           =   2175
  40.    End
  41.    Begin VB.TextBox Text4 
  42.       BeginProperty Font 
  43.          name            =   "MS Sans Serif"
  44.          charset         =   0
  45.          weight          =   400
  46.          size            =   7.8
  47.          underline       =   0   'False
  48.          italic          =   0   'False
  49.          strikethrough   =   0   'False
  50.       EndProperty
  51.       Height          =   615
  52.       Left            =   2040
  53.       TabIndex        =   3
  54.       Text            =   "Text4"
  55.       Top             =   840
  56.       Width           =   1455
  57.    End
  58.    Begin VB.TextBox Text3 
  59.       BeginProperty Font 
  60.          name            =   "MS Sans Serif"
  61.          charset         =   0
  62.          weight          =   400
  63.          size            =   7.8
  64.          underline       =   0   'False
  65.          italic          =   0   'False
  66.          strikethrough   =   0   'False
  67.       EndProperty
  68.       Height          =   495
  69.       Left            =   2160
  70.       TabIndex        =   2
  71.       Text            =   "Text3"
  72.       Top             =   240
  73.       Width           =   1335
  74.    End
  75.    Begin VB.TextBox Text2 
  76.       BeginProperty Font 
  77.          name            =   "MS Sans Serif"
  78.          charset         =   0
  79.          weight          =   400
  80.          size            =   7.8
  81.          underline       =   0   'False
  82.          italic          =   0   'False
  83.          strikethrough   =   0   'False
  84.       EndProperty
  85.       Height          =   495
  86.       Left            =   480
  87.       TabIndex        =   1
  88.       Text            =   "Text2"
  89.       Top             =   240
  90.       Width           =   1455
  91.    End
  92.    Begin VB.TextBox Text1 
  93.       BeginProperty Font 
  94.          name            =   "MS Sans Serif"
  95.          charset         =   0
  96.          weight          =   400
  97.          size            =   7.8
  98.          underline       =   0   'False
  99.          italic          =   0   'False
  100.          strikethrough   =   0   'False
  101.       EndProperty
  102.       Height          =   615
  103.       Left            =   480
  104.       TabIndex        =   0
  105.       Text            =   "Text1"
  106.       Top             =   840
  107.       Width           =   1455
  108.    End
  109. End
  110. Attribute VB_Name = "Form1"
  111. Attribute VB_Creatable = False
  112. Attribute VB_Exposed = False
  113. Option Explicit
  114. Dim x(100) As Integer
  115.  
  116. ' Create a new collection to contain all the
  117. ' text boxes on a form
  118. Dim colTextBoxes As New TextBoxes
  119.  
  120. Private Sub Form_Initialize()
  121.     ' Variable used in For Each to get controls.
  122.     Dim cntrlItem As Control
  123.     ' Loop through the controls on the form.
  124.     For Each cntrlItem In Me.Controls
  125.         ' If the control is a text box, add it to the
  126.         ' collection of text boxes.
  127.         If TypeName(cntrlItem) = "TextBox" Then
  128.             colTextBoxes.Add cntrlItem
  129.         End If
  130.     Next cntrlItem
  131. End Sub
  132.  
  133. Sub cmdClear_Click()
  134.     ' Variable used in For Each to get controls.
  135.     Dim cntrlItem As Control
  136.     ' Clear each of the text boxes in the collection.
  137.     ' This code doesn't work for a type-safe
  138.     ' collection, since they don't support For Each.
  139.     ' For Each cntrlItem In colTextBoxes
  140.         ' cntrlItem.Text = ""
  141.     ' Next cntrlItem
  142.     Dim Index As Integer
  143.     For Index = 1 To colTextBoxes.Count
  144.         colTextBoxes.Item(Index).Text = ""
  145.     Next Index
  146. End Sub
  147.  
  148.  
  149.  
  150.  
  151.  
  152. ' Minimizes all forms in an application.
  153. Sub MinimizeAll()
  154.     Dim frmElement As Form
  155.     ' For each form in the application.
  156.     For Each frmElement In Forms
  157.         ' Minimize the form.
  158.         frmElement.WindowState = vbMinimized
  159.     Next frmElement
  160. End Sub
  161.  
  162. Sub Collection()
  163.     Dim clsOut As New Form1
  164.     Dim colSelection As New Collection
  165.     'clsOut.data = 47
  166.     colSelection.Add Form1.Text1
  167.     MsgBox TypeName(colSelection)
  168. End Sub
  169.  
  170.