home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Variables
- BackColor = &H00C0C0C0&
- Caption = "Code Optimizations"
- ClientHeight = 5220
- ClientLeft = 3405
- ClientTop = 3435
- ClientWidth = 7395
- Height = 5625
- Left = 3345
- LinkTopic = "Form1"
- ScaleHeight = 5220
- ScaleWidth = 7395
- Top = 3090
- Width = 7515
- Begin TextBox txtLoopCount
- Height = 320
- Left = 6000
- TabIndex = 8
- Text = "txtLoopCount"
- Top = 3765
- Width = 1300
- End
- Begin CommandButton cmdExplicit
- Caption = "Explict Property"
- Height = 450
- Left = 120
- TabIndex = 2
- Top = 2280
- Width = 2415
- End
- Begin CommandButton cmdVariable
- Caption = "Variable Test"
- Height = 450
- Left = 120
- TabIndex = 1
- Top = 960
- Width = 1935
- End
- Begin CommandButton cmdVariant
- Caption = "Variant Counter"
- Height = 450
- Left = 120
- TabIndex = 4
- Top = 4190
- Width = 2415
- End
- Begin CommandButton cmdInteger
- Caption = "Integer Counter"
- Height = 450
- Left = 120
- TabIndex = 5
- Top = 4680
- Width = 2415
- End
- Begin TextBox txtValue
- Height = 320
- Left = 6000
- TabIndex = 7
- Text = "txtValue"
- Top = 1800
- Width = 1300
- End
- Begin CommandButton cmdValue
- Caption = "Value of the Control"
- Height = 450
- Left = 120
- TabIndex = 3
- Top = 2780
- Width = 2415
- End
- Begin TextBox txtCounter
- Height = 320
- Left = 6000
- TabIndex = 6
- Text = "txtCounter"
- Top = 60
- Width = 1300
- End
- Begin CommandButton cmdProperty
- Caption = "Property Test"
- Default = -1 'True
- Height = 450
- Left = 120
- TabIndex = 0
- Top = 480
- Width = 1935
- End
- Begin Line Line1
- BorderColor = &H00808080&
- Index = 3
- X1 = -15
- X2 = 7320
- Y1 = 3465
- Y2 = 3465
- End
- Begin Line Line1
- BorderColor = &H00FFFFFF&
- BorderWidth = 2
- Index = 2
- X1 = 0
- X2 = 7335
- Y1 = 3480
- Y2 = 3465
- End
- Begin Line Line1
- BorderColor = &H00808080&
- Index = 1
- X1 = 0
- X2 = 7335
- Y1 = 1680
- Y2 = 1680
- End
- Begin Label lblTitle
- AutoSize = -1 'True
- BackColor = &H00FFFFFF&
- BackStyle = 0 'Transparent
- Caption = "Integer vs. Variant Variables"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 12
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00800000&
- Height = 300
- Index = 0
- Left = 120
- TabIndex = 21
- Top = 3735
- Width = 3675
- End
- Begin Label lblTitle
- AutoSize = -1 'True
- BackColor = &H00FFFFFF&
- BackStyle = 0 'Transparent
- Caption = "Explicit property vs. Value of the Control"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 12
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00800000&
- Height = 300
- Index = 2
- Left = 120
- TabIndex = 20
- Top = 1800
- Width = 5550
- End
- Begin Label lblTitle
- AutoSize = -1 'True
- BackColor = &H00FFFFFF&
- BackStyle = 0 'Transparent
- Caption = "Variables vs. Property Access"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 12
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00800000&
- Height = 300
- Index = 1
- Left = 120
- TabIndex = 19
- Top = 120
- Width = 3855
- End
- Begin Label lblVariant
- BackStyle = 0 'Transparent
- Caption = "00.00 secs"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 250
- Left = 6000
- TabIndex = 18
- Top = 4290
- Width = 1800
- End
- Begin Label lblInteger
- BackStyle = 0 'Transparent
- Caption = "00.00 secs"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 250
- Left = 6000
- TabIndex = 17
- Top = 4785
- Width = 1800
- End
- Begin Label Label1
- BackStyle = 0 'Transparent
- Caption = "Use the explicit Text property:"
- Height = 250
- Index = 3
- Left = 2700
- TabIndex = 16
- Top = 2385
- Width = 2700
- End
- Begin Label lblExplicit
- BackStyle = 0 'Transparent
- Caption = "00.00 secs"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 250
- Left = 6000
- TabIndex = 15
- Top = 2385
- Width = 1300
- End
- Begin Label Label1
- BackStyle = 0 'Transparent
- Caption = "Use value of the control:"
- Height = 250
- Index = 2
- Left = 2700
- TabIndex = 14
- Top = 2880
- Width = 2700
- End
- Begin Label lblValue
- BackStyle = 0 'Transparent
- Caption = "00.00 secs"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 250
- Left = 6000
- TabIndex = 13
- Top = 2880
- Width = 1300
- End
- Begin Line Line1
- BorderColor = &H00FFFFFF&
- BorderWidth = 2
- Index = 0
- X1 = 15
- X2 = 7350
- Y1 = 1695
- Y2 = 1680
- End
- Begin Label lblVariable
- BackStyle = 0 'Transparent
- Caption = "00.00 secs"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 250
- Left = 6000
- TabIndex = 12
- Top = 1080
- Width = 1300
- End
- Begin Label Label1
- BackStyle = 0 'Transparent
- Caption = "Using a Variable in the loop:"
- Height = 250
- Index = 1
- Left = 2150
- TabIndex = 11
- Top = 1080
- Width = 3100
- End
- Begin Label lblProperty
- BackStyle = 0 'Transparent
- Caption = "00.00 secs"
- FontBold = -1 'True
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 9.75
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 250
- Left = 6000
- TabIndex = 10
- Top = 585
- Width = 1300
- End
- Begin Label Label1
- BackStyle = 0 'Transparent
- Caption = "Using the Text property in the loop:"
- Height = 250
- Index = 0
- Left = 2145
- TabIndex = 9
- Top = 585
- Width = 3105
- End
- Sub cmdExplicit_Click ()
- 'Use the explicit property (txtValue.Text) reference
- 'Sub cmdValue_Click is slightly faster
- Limit% = Val(txtValue)
- screen.MousePointer = 11
- Start = Timer
- For x% = 1 To Limit%
- foo$ = txtValue.Text
- Next x%
- Finish = Timer
- screen.MousePointer = 0
- lblExplicit = Format$(Finish - Start, "##.##") & " secs."
- End Sub
- Sub cmdInteger_Click ()
- 'Use an Integer as the Loop Counter
- 'faster than Sub cmdVariant_Click
- Dim intCounter1 As Integer, intCounter2 As Integer, intCounter3 As Integer
- screen.MousePointer = 11
- Start = Timer
- For intCounter1 = 1 To 100
- For intCounter2 = 1 To intCounter1
- For intCounter3 = 1 To intCounter2
- var = intCounter3 * 100 + intCounter2 * 10 + intCounter1
- Next intCounter3
- Next intCounter2
- Next intCounter1
- Finish = Timer
- screen.MousePointer = 0
- lblInteger = Format$(Finish - Start, "##.##") & " secs."
- End Sub
- Sub cmdProperty_Click ()
- 'In each iteration, reference the Text Property
- 'Sub cmdVariable_Click is faster
- Limit% = Val(txtCounter.Text)
- screen.MousePointer = 11
- Start = Timer
- For x% = 1 To Limit%
- foo$ = Left(txtCounter.Text, Len(txtCounter.Text \ 2))
- Next x%
- Finish = Timer
- screen.MousePointer = 0
- lblProperty = Format$(Finish - Start, "##.##") & " secs."
- End Sub
- Sub cmdValue_Click ()
- 'Use the Value of the control by omitting the explicit Text property
- 'slightly faster than Sub cmdExplicit_Click
- Limit% = Val(txtValue)
- screen.MousePointer = 11
- Start = Timer
- For x% = 1 To Limit%
- foo$ = txtValue
- Next x%
- Finish = Timer
- screen.MousePointer = 0
- lblValue = Format$(Finish - Start, "##.##") & " secs."
- End Sub
- Sub cmdVariable_Click ()
- 'Use a Variable (Temp$) instead of a Property Access
- 'faster than Sub cmdProperty_Click
- Limit% = Val(txtLoopCount.Text)
- Temp$ = txtLoopCount.Text
- screen.MousePointer = 11
- Start = Timer
- For varCounter1 = 1 To txtLoopCount.Text
- For varCounter2 = 1 To varCounter1
- For varCounter3 = 1 To varCounter2
- var = varCounter3 * 100 + varCounter2 * 10 + varCounter1
- Next varCounter3
- Next varCounter2
- Next varCounter1
- Finish = Timer
- screen.MousePointer = 0
- lblVariable = Format$(Finish - Start, "##.##") & " secs."
- End Sub
- Sub cmdVariant_Click ()
- 'Use a Variant as the Loop Counter.
- 'Sub cmdInteger_Click is faster since it uses a Integer as the Loop Counter
- screen.MousePointer = 11
- Start = Timer
- For varCounter1 = 1 To txtLoopCount.Text
- For varCounter2 = 1 To varCounter1
- For varCounter3 = 1 To varCounter2
- var = varCounter3 * 100 + varCounter2 * 10 + varCounter1
- Next varCounter3
- Next varCounter2
- Next varCounter1
- Finish = Timer
- screen.MousePointer = 0
- lblVariant = Format$(Finish - Start, "##.##") & " secs."
- End Sub
- Sub Form_Load ()
- 'Center the form on load.
- Me.Left = (screen.Width - Me.Width) / 2
- Me.Top = (screen.Height - Me.Height) / 2
- ' Set default counter values
- txtCounter = 1000
- txtValue = 1000
- txtLoopCount = 100
- End Sub
-