home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / PVb5.0 / VB / SAMPLES / PGUIDE / OPTIMIZE / COLLECTN.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-01-22  |  17.2 KB  |  527 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.1#0"; "COMCTL32.OCX"
  3. Begin VB.Form frmCollection 
  4.    Caption         =   "
  5.    ClientHeight    =   5970
  6.    ClientLeft      =   4320
  7.    ClientTop       =   1755
  8.    ClientWidth     =   5865
  9.    LinkTopic       =   "Form1"
  10.    LockControls    =   -1  'True
  11.    PaletteMode     =   1  'UseZOrder
  12.    ScaleHeight     =   5970
  13.    ScaleWidth      =   5865
  14.    Begin VB.CommandButton cmdType 
  15.       Caption         =   "For Next"
  16.       Height          =   450
  17.       HelpContextID   =   1
  18.       Index           =   6
  19.       Left            =   120
  20.       TabIndex        =   8
  21.       Top             =   4980
  22.       Width           =   2415
  23.    End
  24.    Begin VB.CommandButton cmdType 
  25.       Caption         =   "For Each"
  26.       Height          =   450
  27.       Index           =   5
  28.       Left            =   120
  29.       TabIndex        =   7
  30.       Top             =   4485
  31.       Width           =   2415
  32.    End
  33.    Begin VB.TextBox txtLoopCount 
  34.       Height          =   320
  35.       Index           =   2
  36.       Left            =   4605
  37.       TabIndex        =   9
  38.       Text            =   "2000"
  39.       Top             =   4050
  40.       Width           =   1150
  41.    End
  42.    Begin VB.CommandButton cmdType 
  43.       Caption         =   "
  44.       Height          =   450
  45.       HelpContextID   =   1
  46.       Index           =   4
  47.       Left            =   120
  48.       TabIndex        =   5
  49.       Top             =   3255
  50.       Width           =   2415
  51.    End
  52.    Begin VB.CommandButton cmdType 
  53.       Caption         =   "
  54.       Height          =   450
  55.       Index           =   3
  56.       Left            =   120
  57.       TabIndex        =   4
  58.       Top             =   2760
  59.       Width           =   2415
  60.    End
  61.    Begin VB.TextBox txtLoopCount 
  62.       Height          =   320
  63.       Index           =   1
  64.       Left            =   4600
  65.       TabIndex        =   6
  66.       Text            =   "2000"
  67.       Top             =   2325
  68.       Width           =   1150
  69.    End
  70.    Begin VB.CommandButton cmdType 
  71.       Caption         =   "
  72.       Height          =   450
  73.       HelpContextID   =   1
  74.       Index           =   2
  75.       Left            =   120
  76.       TabIndex        =   2
  77.       Top             =   1500
  78.       Width           =   2415
  79.    End
  80.    Begin VB.TextBox txtLoopCount 
  81.       Height          =   320
  82.       Index           =   0
  83.       Left            =   4600
  84.       TabIndex        =   3
  85.       Text            =   "1000"
  86.       Top             =   75
  87.       Width           =   1150
  88.    End
  89.    Begin VB.CommandButton cmdType 
  90.       Caption         =   "
  91.       Height          =   450
  92.       Index           =   0
  93.       Left            =   120
  94.       TabIndex        =   0
  95.       Top             =   510
  96.       Width           =   2415
  97.    End
  98.    Begin VB.CommandButton cmdType 
  99.       Caption         =   "
  100.       Height          =   450
  101.       HelpContextID   =   1
  102.       Index           =   1
  103.       Left            =   120
  104.       TabIndex        =   1
  105.       Top             =   1005
  106.       Width           =   2415
  107.    End
  108.    Begin ComctlLib.ProgressBar ProgBar 
  109.       Height          =   195
  110.       Left            =   2880
  111.       TabIndex        =   21
  112.       Top             =   5745
  113.       Width           =   2700
  114.       _ExtentX        =   4763
  115.       _ExtentY        =   344
  116.       Appearance      =   1
  117.    End
  118.    Begin ComctlLib.StatusBar StatusBar 
  119.       Align           =   2  'Align Bottom
  120.       Height          =   270
  121.       Left            =   0
  122.       TabIndex        =   20
  123.       Top             =   5700
  124.       Width           =   5865
  125.       _ExtentX        =   10345
  126.       _ExtentY        =   476
  127.       SimpleText      =   ""
  128.       BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7} 
  129.          NumPanels       =   2
  130.          BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
  131.             Object.Width           =   4939
  132.             MinWidth        =   4939
  133.             TextSave        =   ""
  134.             Object.Tag             =   ""
  135.          EndProperty
  136.          BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7} 
  137.             Object.Width           =   4904
  138.             MinWidth        =   4904
  139.             TextSave        =   ""
  140.             Object.Tag             =   ""
  141.          EndProperty
  142.       EndProperty
  143.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  144.          Name            =   "
  145.          Size            =   9
  146.          Charset         =   134
  147.          Weight          =   400
  148.          Underline       =   0   'False
  149.          Italic          =   0   'False
  150.          Strikethrough   =   0   'False
  151.       EndProperty
  152.    End
  153.    Begin VB.Label lblResult 
  154.       Appearance      =   0  'Flat
  155.       BackColor       =   &H80000005&
  156.       BackStyle       =   0  'Transparent
  157.       Caption         =   "00.00 
  158.       BeginProperty Font 
  159.          Name            =   "
  160.          Size            =   9.75
  161.          Charset         =   134
  162.          Weight          =   400
  163.          Underline       =   0   'False
  164.          Italic          =   0   'False
  165.          Strikethrough   =   0   'False
  166.       EndProperty
  167.       ForeColor       =   &H80000008&
  168.       Height          =   255
  169.       Index           =   6
  170.       Left            =   4605
  171.       TabIndex        =   19
  172.       Top             =   5085
  173.       Width           =   1155
  174.    End
  175.    Begin VB.Label lblResult 
  176.       Appearance      =   0  'Flat
  177.       BackColor       =   &H80000005&
  178.       BackStyle       =   0  'Transparent
  179.       Caption         =   "00.00 
  180.       BeginProperty Font 
  181.          Name            =   "
  182.          Size            =   9.75
  183.          Charset         =   134
  184.          Weight          =   400
  185.          Underline       =   0   'False
  186.          Italic          =   0   'False
  187.          Strikethrough   =   0   'False
  188.       EndProperty
  189.       ForeColor       =   &H80000008&
  190.       Height          =   255
  191.       Index           =   5
  192.       Left            =   4605
  193.       TabIndex        =   18
  194.       Top             =   4590
  195.       Width           =   1155
  196.    End
  197.    Begin VB.Label lblTitle 
  198.       Appearance      =   0  'Flat
  199.       AutoSize        =   -1  'True
  200.       BackColor       =   &H00FFFFFF&
  201.       BackStyle       =   0  'Transparent
  202.       Caption         =   "For Each 
  203.  For Next"
  204.       BeginProperty Font 
  205.          Name            =   "
  206.          Size            =   12
  207.          Charset         =   134
  208.          Weight          =   700
  209.          Underline       =   0   'False
  210.          Italic          =   0   'False
  211.          Strikethrough   =   0   'False
  212.       EndProperty
  213.       ForeColor       =   &H00800000&
  214.       Height          =   300
  215.       Index           =   2
  216.       Left            =   135
  217.       TabIndex        =   17
  218.       Top             =   4050
  219.       Width           =   2535
  220.    End
  221.    Begin VB.Line Line1 
  222.       BorderColor     =   &H00808080&
  223.       Index           =   0
  224.       X1              =   0
  225.       X2              =   7335
  226.       Y1              =   3900
  227.       Y2              =   3900
  228.    End
  229.    Begin VB.Label lblResult 
  230.       Appearance      =   0  'Flat
  231.       BackColor       =   &H80000005&
  232.       BackStyle       =   0  'Transparent
  233.       Caption         =   "00.00 
  234.       BeginProperty Font 
  235.          Name            =   "
  236.          Size            =   9.75
  237.          Charset         =   134
  238.          Weight          =   400
  239.          Underline       =   0   'False
  240.          Italic          =   0   'False
  241.          Strikethrough   =   0   'False
  242.       EndProperty
  243.       ForeColor       =   &H80000008&
  244.       Height          =   255
  245.       Index           =   4
  246.       Left            =   4600
  247.       TabIndex        =   16
  248.       Top             =   3360
  249.       Width           =   1155
  250.    End
  251.    Begin VB.Label lblResult 
  252.       Appearance      =   0  'Flat
  253.       BackColor       =   &H80000005&
  254.       BackStyle       =   0  'Transparent
  255.       Caption         =   "00.00 
  256.       BeginProperty Font 
  257.          Name            =   "
  258.          Size            =   9.75
  259.          Charset         =   134
  260.          Weight          =   400
  261.          Underline       =   0   'False
  262.          Italic          =   0   'False
  263.          Strikethrough   =   0   'False
  264.       EndProperty
  265.       ForeColor       =   &H80000008&
  266.       Height          =   255
  267.       Index           =   3
  268.       Left            =   4600
  269.       TabIndex        =   15
  270.       Top             =   2865
  271.       Width           =   1155
  272.    End
  273.    Begin VB.Label lblTitle 
  274.       Appearance      =   0  'Flat
  275.       AutoSize        =   -1  'True
  276.       BackColor       =   &H00FFFFFF&
  277.       BackStyle       =   0  'Transparent
  278.       Caption         =   "
  279.       BeginProperty Font 
  280.          Name            =   "
  281.          Size            =   12
  282.          Charset         =   134
  283.          Weight          =   700
  284.          Underline       =   0   'False
  285.          Italic          =   0   'False
  286.          Strikethrough   =   0   'False
  287.       EndProperty
  288.       ForeColor       =   &H00800000&
  289.       Height          =   300
  290.       Index           =   1
  291.       Left            =   135
  292.       TabIndex        =   14
  293.       Top             =   2325
  294.       Width           =   1290
  295.    End
  296.    Begin VB.Line Line1 
  297.       BorderColor     =   &H00808080&
  298.       Index           =   3
  299.       X1              =   0
  300.       X2              =   7335
  301.       Y1              =   2175
  302.       Y2              =   2175
  303.    End
  304.    Begin VB.Label lblResult 
  305.       Appearance      =   0  'Flat
  306.       BackColor       =   &H80000005&
  307.       BackStyle       =   0  'Transparent
  308.       Caption         =   "00.00 
  309.       BeginProperty Font 
  310.          Name            =   "
  311.          Size            =   9.75
  312.          Charset         =   134
  313.          Weight          =   400
  314.          Underline       =   0   'False
  315.          Italic          =   0   'False
  316.          Strikethrough   =   0   'False
  317.       EndProperty
  318.       ForeColor       =   &H80000008&
  319.       Height          =   255
  320.       Index           =   2
  321.       Left            =   4600
  322.       TabIndex        =   13
  323.       Top             =   1600
  324.       Width           =   1150
  325.    End
  326.    Begin VB.Label lblTitle 
  327.       Appearance      =   0  'Flat
  328.       AutoSize        =   -1  'True
  329.       BackColor       =   &H00FFFFFF&
  330.       BackStyle       =   0  'Transparent
  331.       Caption         =   "
  332.       BeginProperty Font 
  333.          Name            =   "
  334.          Size            =   12
  335.          Charset         =   134
  336.          Weight          =   700
  337.          Underline       =   0   'False
  338.          Italic          =   0   'False
  339.          Strikethrough   =   0   'False
  340.       EndProperty
  341.       ForeColor       =   &H00800000&
  342.       Height          =   300
  343.       Index           =   0
  344.       Left            =   135
  345.       TabIndex        =   12
  346.       Top             =   75
  347.       Width           =   1290
  348.    End
  349.    Begin VB.Label lblResult 
  350.       Appearance      =   0  'Flat
  351.       BackColor       =   &H80000005&
  352.       BackStyle       =   0  'Transparent
  353.       Caption         =   "00.00 
  354.       BeginProperty Font 
  355.          Name            =   "
  356.          Size            =   9.75
  357.          Charset         =   134
  358.          Weight          =   400
  359.          Underline       =   0   'False
  360.          Italic          =   0   'False
  361.          Strikethrough   =   0   'False
  362.       EndProperty
  363.       ForeColor       =   &H80000008&
  364.       Height          =   255
  365.       Index           =   0
  366.       Left            =   4600
  367.       TabIndex        =   11
  368.       Top             =   615
  369.       Width           =   1150
  370.    End
  371.    Begin VB.Label lblResult 
  372.       Appearance      =   0  'Flat
  373.       BackColor       =   &H80000005&
  374.       BackStyle       =   0  'Transparent
  375.       Caption         =   "00.00 
  376.       BeginProperty Font 
  377.          Name            =   "
  378.          Size            =   9.75
  379.          Charset         =   134
  380.          Weight          =   400
  381.          Underline       =   0   'False
  382.          Italic          =   0   'False
  383.          Strikethrough   =   0   'False
  384.       EndProperty
  385.       ForeColor       =   &H80000008&
  386.       Height          =   255
  387.       Index           =   1
  388.       Left            =   4600
  389.       TabIndex        =   10
  390.       Top             =   1110
  391.       Width           =   1150
  392.    End
  393.    Begin VB.Line Line1 
  394.       BorderColor     =   &H00FFFFFF&
  395.       BorderWidth     =   2
  396.       Index           =   2
  397.       X1              =   15
  398.       X2              =   7350
  399.       Y1              =   2190
  400.       Y2              =   2175
  401.    End
  402.    Begin VB.Line Line1 
  403.       BorderColor     =   &H00FFFFFF&
  404.       BorderWidth     =   2
  405.       Index           =   1
  406.       X1              =   15
  407.       X2              =   7350
  408.       Y1              =   3915
  409.       Y2              =   3900
  410.    End
  411. Attribute VB_Name = "frmCollection"
  412. Attribute VB_GlobalNameSpace = False
  413. Attribute VB_Creatable = False
  414. Attribute VB_PredeclaredId = True
  415. Attribute VB_Exposed = False
  416. Option Explicit
  417. Private Sub cmdType_Click(Index As Integer)
  418.   Dim MyCollection As New Collection
  419.   Dim iCounter As Integer
  420.   Dim dStart As Double, dFinish As Double
  421.   Dim sAnswer As String
  422.   Dim pnlStatus As Panel
  423.   Dim vItem As Variant
  424.   Set pnlStatus = frmCollection.StatusBar.Panels(1)
  425.   Screen.MousePointer = vbHourglass
  426.   dStart = Timer
  427.   Select Case Index
  428.     Case 0  '
  429.       For iCounter = 0 To Val(txtLoopCount(0).Text) Step 3
  430.         MyCollection.Add Item:=CStr(iCounter), Key:=CStr(iCounter)
  431.         MyCollection.Add Item:=CStr(iCounter + 400), Key:=CStr(iCounter + 1)
  432.         MyCollection.Add Item:=CStr(iCounter + 800), Key:=CStr(iCounter + 2)
  433.       Next iCounter
  434.     Case 1 '
  435.       MyCollection.Add Item:=CStr(1), Key:=CStr(1)
  436.       For iCounter = 2 To Val(txtLoopCount(0).Text) Step 3
  437.         MyCollection.Add Item:=CStr(iCounter), Key:=CStr(iCounter), Before:=CStr(iCounter - 1)
  438.         MyCollection.Add Item:=CStr(iCounter + 400), Key:=CStr(iCounter + 1), Before:=CStr(iCounter)
  439.         MyCollection.Add Item:=CStr(iCounter + 800), Key:=CStr(iCounter + 2), Before:=CStr(iCounter)
  440.       Next iCounter
  441.     Case 2 '
  442.       MyCollection.Add Item:=CStr(1), Key:=CStr(1)
  443.       For iCounter = 2 To Val(txtLoopCount(0).Text) Step 3
  444.         MyCollection.Add Item:=CStr(iCounter), Key:=CStr(iCounter), After:=CStr(iCounter - 1)
  445.         MyCollection.Add Item:=CStr(iCounter + 400), Key:=CStr(iCounter + 1), After:=CStr(iCounter)
  446.         MyCollection.Add Item:=CStr(iCounter + 800), Key:=CStr(iCounter + 2), After:=CStr(iCounter)
  447.       Next iCounter
  448.     Case 3  ' 
  449.       pnlStatus.Text = "
  450.       StatusBar.Refresh
  451.       ProgBar.Max = Val(txtLoopCount(1).Text)
  452.       ' 
  453.       For iCounter = 1 To Val(txtLoopCount(1).Text)
  454.         If iCounter Mod 10 = 0 Then ProgBar.Value = iCounter
  455.         MyCollection.Add Item:=CStr(iCounter), Key:=CStr(iCounter)
  456.       Next iCounter
  457.       
  458.       pnlStatus.Text = "
  459.       StatusBar.Refresh
  460.       dStart = Timer
  461.       For iCounter = MyCollection.Count To 1 Step -1
  462.         sAnswer = MyCollection(CStr(iCounter))
  463.       Next iCounter
  464.       
  465.     Case 4  ' 
  466.       pnlStatus.Text = "
  467.       StatusBar.Refresh
  468.       ProgBar.Max = Val(txtLoopCount(1).Text)
  469.       ' 
  470.       For iCounter = 1 To Val(txtLoopCount(1).Text)
  471.         If iCounter Mod 10 = 0 Then ProgBar.Value = iCounter
  472.         MyCollection.Add Item:=CStr(iCounter), Key:=CStr(iCounter)
  473.       Next iCounter
  474.       
  475.       pnlStatus.Text = "
  476.       StatusBar.Refresh
  477.       dStart = Timer
  478.       For iCounter = MyCollection.Count To 1 Step -1
  479.         sAnswer = MyCollection(iCounter)
  480.       Next iCounter
  481.     Case 5  ' For Each
  482.       pnlStatus.Text = "
  483.       StatusBar.Refresh
  484.       ProgBar.Max = Val(txtLoopCount(2).Text)
  485.       
  486.       For iCounter = 1 To Val(txtLoopCount(2).Text)
  487.         If iCounter Mod 10 = 0 Then ProgBar.Value = iCounter
  488.         MyCollection.Add Item:=CStr(iCounter), Key:=CStr(iCounter)
  489.       Next iCounter
  490.       
  491.       pnlStatus.Text = "
  492.       StatusBar.Refresh
  493.       
  494.       dStart = Timer
  495.       For Each vItem In MyCollection
  496.         sAnswer = MyCollection(vItem)
  497.       Next vItem
  498.     Case 6  ' For Next
  499.       pnlStatus.Text = "
  500.       StatusBar.Refresh
  501.       ProgBar.Max = Val(txtLoopCount(2).Text)
  502.       
  503.       For iCounter = 1 To Val(txtLoopCount(2).Text)
  504.         If iCounter Mod 10 = 0 Then ProgBar.Value = iCounter
  505.         MyCollection.Add Item:=CStr(iCounter), Key:=CStr(iCounter)
  506.       Next iCounter
  507.       
  508.       pnlStatus.Text = "
  509.       StatusBar.Refresh
  510.       
  511.       dStart = Timer
  512.       For iCounter = 1 To MyCollection.Count
  513.         sAnswer = MyCollection(iCounter)
  514.       Next iCounter
  515.       
  516.   End Select
  517.   dFinish = Timer
  518.   Set MyCollection = Nothing
  519.   lblResult(Index).Caption = Format$(dFinish - dStart, "00.00") & " 
  520.   pnlStatus.Text = ""
  521.   ProgBar.Value = 0
  522.   Screen.MousePointer = vbDefault
  523. End Sub
  524. Private Sub Form_Load()
  525.   PosForm Me
  526. End Sub
  527.