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

  1. VERSION 5.00
  2. Begin VB.Form frmNumbers 
  3.    Caption         =   "
  4.    ClientHeight    =   5220
  5.    ClientLeft      =   1125
  6.    ClientTop       =   1575
  7.    ClientWidth     =   5580
  8.    ClipControls    =   0   'False
  9.    LinkTopic       =   "Form1"
  10.    LockControls    =   -1  'True
  11.    PaletteMode     =   1  'UseZOrder
  12.    ScaleHeight     =   5220
  13.    ScaleWidth      =   5580
  14.    Begin VB.CommandButton cmdType 
  15.       Caption         =   "Double"
  16.       Height          =   450
  17.       Index           =   5
  18.       Left            =   135
  19.       TabIndex        =   7
  20.       Top             =   4680
  21.       Width           =   2415
  22.    End
  23.    Begin VB.CommandButton cmdType 
  24.       Caption         =   "Currency"
  25.       Height          =   450
  26.       Index           =   4
  27.       Left            =   135
  28.       TabIndex        =   6
  29.       Top             =   4185
  30.       Width           =   2415
  31.    End
  32.    Begin VB.TextBox txtLoopCount 
  33.       Height          =   320
  34.       Index           =   2
  35.       Left            =   4200
  36.       TabIndex        =   8
  37.       Text            =   "200"
  38.       Top             =   3765
  39.       Width           =   1300
  40.    End
  41.    Begin VB.CommandButton cmdType 
  42.       Caption         =   "Long 
  43.       Height          =   450
  44.       Index           =   3
  45.       Left            =   135
  46.       TabIndex        =   4
  47.       Top             =   2910
  48.       Width           =   2415
  49.    End
  50.    Begin VB.CommandButton cmdType 
  51.       Caption         =   "Variant 
  52.       Height          =   450
  53.       Index           =   2
  54.       Left            =   135
  55.       TabIndex        =   3
  56.       Top             =   2415
  57.       Width           =   2415
  58.    End
  59.    Begin VB.TextBox txtLoopCount 
  60.       Height          =   320
  61.       Index           =   1
  62.       Left            =   4200
  63.       TabIndex        =   5
  64.       Text            =   "200"
  65.       Top             =   1995
  66.       Width           =   1300
  67.    End
  68.    Begin VB.CommandButton cmdType 
  69.       Caption         =   "Integer 
  70.       Height          =   450
  71.       HelpContextID   =   1
  72.       Index           =   1
  73.       Left            =   120
  74.       TabIndex        =   1
  75.       Top             =   975
  76.       Width           =   2415
  77.    End
  78.    Begin VB.CommandButton cmdType 
  79.       Caption         =   "Long 
  80.       Height          =   450
  81.       Index           =   0
  82.       Left            =   120
  83.       TabIndex        =   0
  84.       Top             =   480
  85.       Width           =   2415
  86.    End
  87.    Begin VB.TextBox txtLoopCount 
  88.       Height          =   320
  89.       Index           =   0
  90.       Left            =   4200
  91.       TabIndex        =   2
  92.       Text            =   "200"
  93.       Top             =   60
  94.       Width           =   1300
  95.    End
  96.    Begin VB.Label lblResult 
  97.       Appearance      =   0  'Flat
  98.       BackColor       =   &H80000005&
  99.       BackStyle       =   0  'Transparent
  100.       Caption         =   "00.00 
  101.       BeginProperty Font 
  102.          Name            =   "
  103.          Size            =   9.75
  104.          Charset         =   134
  105.          Weight          =   400
  106.          Underline       =   0   'False
  107.          Italic          =   0   'False
  108.          Strikethrough   =   0   'False
  109.       EndProperty
  110.       ForeColor       =   &H80000008&
  111.       Height          =   255
  112.       Index           =   5
  113.       Left            =   4200
  114.       TabIndex        =   17
  115.       Top             =   4785
  116.       Width           =   1800
  117.    End
  118.    Begin VB.Label lblResult 
  119.       Appearance      =   0  'Flat
  120.       BackColor       =   &H80000005&
  121.       BackStyle       =   0  'Transparent
  122.       Caption         =   "00.00 
  123.       BeginProperty Font 
  124.          Name            =   "
  125.          Size            =   9.75
  126.          Charset         =   134
  127.          Weight          =   400
  128.          Underline       =   0   'False
  129.          Italic          =   0   'False
  130.          Strikethrough   =   0   'False
  131.       EndProperty
  132.       ForeColor       =   &H80000008&
  133.       Height          =   255
  134.       Index           =   4
  135.       Left            =   4200
  136.       TabIndex        =   16
  137.       Top             =   4290
  138.       Width           =   1800
  139.    End
  140.    Begin VB.Label lblTitle 
  141.       Appearance      =   0  'Flat
  142.       AutoSize        =   -1  'True
  143.       BackColor       =   &H00FFFFFF&
  144.       BackStyle       =   0  'Transparent
  145.       Caption         =   "Double 
  146.  Currency 
  147.       BeginProperty Font 
  148.          Name            =   "
  149.          Size            =   12
  150.          Charset         =   134
  151.          Weight          =   700
  152.          Underline       =   0   'False
  153.          Italic          =   0   'False
  154.          Strikethrough   =   0   'False
  155.       EndProperty
  156.       ForeColor       =   &H00800000&
  157.       Height          =   300
  158.       Index           =   2
  159.       Left            =   135
  160.       TabIndex        =   15
  161.       Top             =   3750
  162.       Width           =   2925
  163.    End
  164.    Begin VB.Line Line1 
  165.       BorderColor     =   &H00808080&
  166.       Index           =   0
  167.       X1              =   0
  168.       X2              =   7335
  169.       Y1              =   3465
  170.       Y2              =   3465
  171.    End
  172.    Begin VB.Label lblResult 
  173.       Appearance      =   0  'Flat
  174.       BackColor       =   &H80000005&
  175.       BackStyle       =   0  'Transparent
  176.       Caption         =   "00.00 
  177.       BeginProperty Font 
  178.          Name            =   "
  179.          Size            =   9.75
  180.          Charset         =   134
  181.          Weight          =   400
  182.          Underline       =   0   'False
  183.          Italic          =   0   'False
  184.          Strikethrough   =   0   'False
  185.       EndProperty
  186.       ForeColor       =   &H80000008&
  187.       Height          =   255
  188.       Index           =   3
  189.       Left            =   4200
  190.       TabIndex        =   14
  191.       Top             =   3015
  192.       Width           =   1800
  193.    End
  194.    Begin VB.Label lblResult 
  195.       Appearance      =   0  'Flat
  196.       BackColor       =   &H80000005&
  197.       BackStyle       =   0  'Transparent
  198.       Caption         =   "00.00 
  199.       BeginProperty Font 
  200.          Name            =   "
  201.          Size            =   9.75
  202.          Charset         =   134
  203.          Weight          =   400
  204.          Underline       =   0   'False
  205.          Italic          =   0   'False
  206.          Strikethrough   =   0   'False
  207.       EndProperty
  208.       ForeColor       =   &H80000008&
  209.       Height          =   255
  210.       Index           =   2
  211.       Left            =   4200
  212.       TabIndex        =   13
  213.       Top             =   2520
  214.       Width           =   1800
  215.    End
  216.    Begin VB.Label lblTitle 
  217.       Appearance      =   0  'Flat
  218.       AutoSize        =   -1  'True
  219.       BackColor       =   &H00FFFFFF&
  220.       BackStyle       =   0  'Transparent
  221.       Caption         =   "Long 
  222.  Variant 
  223.       BeginProperty Font 
  224.          Name            =   "
  225.          Size            =   12
  226.          Charset         =   134
  227.          Weight          =   700
  228.          Underline       =   0   'False
  229.          Italic          =   0   'False
  230.          Strikethrough   =   0   'False
  231.       EndProperty
  232.       ForeColor       =   &H00800000&
  233.       Height          =   300
  234.       Index           =   1
  235.       Left            =   135
  236.       TabIndex        =   12
  237.       Top             =   1980
  238.       Width           =   2475
  239.    End
  240.    Begin VB.Line Line1 
  241.       BorderColor     =   &H00808080&
  242.       Index           =   3
  243.       X1              =   0
  244.       X2              =   7335
  245.       Y1              =   1680
  246.       Y2              =   1680
  247.    End
  248.    Begin VB.Label lblResult 
  249.       Appearance      =   0  'Flat
  250.       BackColor       =   &H80000005&
  251.       BackStyle       =   0  'Transparent
  252.       Caption         =   "00.00 
  253.       BeginProperty Font 
  254.          Name            =   "
  255.          Size            =   9.75
  256.          Charset         =   134
  257.          Weight          =   400
  258.          Underline       =   0   'False
  259.          Italic          =   0   'False
  260.          Strikethrough   =   0   'False
  261.       EndProperty
  262.       ForeColor       =   &H80000008&
  263.       Height          =   255
  264.       Index           =   1
  265.       Left            =   4200
  266.       TabIndex        =   11
  267.       Top             =   1080
  268.       Width           =   1800
  269.    End
  270.    Begin VB.Label lblResult 
  271.       Appearance      =   0  'Flat
  272.       BackColor       =   &H80000005&
  273.       BackStyle       =   0  'Transparent
  274.       Caption         =   "00.00 
  275.       BeginProperty Font 
  276.          Name            =   "
  277.          Size            =   9.75
  278.          Charset         =   134
  279.          Weight          =   400
  280.          Underline       =   0   'False
  281.          Italic          =   0   'False
  282.          Strikethrough   =   0   'False
  283.       EndProperty
  284.       ForeColor       =   &H80000008&
  285.       Height          =   255
  286.       Index           =   0
  287.       Left            =   4200
  288.       TabIndex        =   10
  289.       Top             =   585
  290.       Width           =   1800
  291.    End
  292.    Begin VB.Label lblTitle 
  293.       Appearance      =   0  'Flat
  294.       AutoSize        =   -1  'True
  295.       BackColor       =   &H00FFFFFF&
  296.       BackStyle       =   0  'Transparent
  297.       Caption         =   "Integer 
  298.  Long 
  299.       BeginProperty Font 
  300.          Name            =   "
  301.          Size            =   12
  302.          Charset         =   134
  303.          Weight          =   700
  304.          Underline       =   0   'False
  305.          Italic          =   0   'False
  306.          Strikethrough   =   0   'False
  307.       EndProperty
  308.       ForeColor       =   &H00800000&
  309.       Height          =   240
  310.       Index           =   0
  311.       Left            =   120
  312.       TabIndex        =   9
  313.       Top             =   45
  314.       Width           =   2670
  315.    End
  316.    Begin VB.Line Line1 
  317.       BorderColor     =   &H00FFFFFF&
  318.       BorderWidth     =   2
  319.       Index           =   2
  320.       X1              =   15
  321.       X2              =   7350
  322.       Y1              =   1695
  323.       Y2              =   1680
  324.    End
  325.    Begin VB.Line Line1 
  326.       BorderColor     =   &H00FFFFFF&
  327.       BorderWidth     =   2
  328.       Index           =   1
  329.       X1              =   15
  330.       X2              =   7350
  331.       Y1              =   3480
  332.       Y2              =   3465
  333.    End
  334. Attribute VB_Name = "frmNumbers"
  335. Attribute VB_GlobalNameSpace = False
  336. Attribute VB_Creatable = False
  337. Attribute VB_PredeclaredId = True
  338. Attribute VB_Exposed = False
  339. Option Explicit
  340. Private Sub cmdType_Click(Index As Integer)
  341.   Dim vCounter1 As Variant, vCounter2 As Variant, vCounter3 As Variant, vResult As Variant
  342.   Dim lCounter1 As Long, lCounter2 As Long, lCounter3 As Long, lResult As Long
  343.   Dim iCounter1 As Integer, iCounter2 As Integer, iCounter3 As Integer, iResult As Integer
  344.   Dim dCounter1 As Double, dCounter2 As Double, dCounter3 As Double, dResult As Double
  345.   Dim cCounter1 As Currency, cCounter2 As Currency, cCounter3 As Currency, cResult As Currency
  346.   Dim start As Double, Finish As Double
  347.   On Error GoTo cmd_Error
  348.   Screen.MousePointer = vbHourglass
  349.   lblResult(Index).Caption = "0.00 
  350.   lblResult(Index).Refresh
  351.   Select Case Index
  352.     Case 0 ' Long 
  353.       start = Timer
  354.       For lCounter1 = 1 To txtLoopCount(0).Text
  355.           For lCounter2 = 1 To lCounter1
  356.               For lCounter3 = 1 To lCounter2
  357.                   lResult = lCounter3 * 100 + lCounter2 * 10 + lCounter1
  358.               Next lCounter3
  359.           Next lCounter2
  360.       Next lCounter1
  361.       Finish = Timer
  362.     Case 1  ' Integer 
  363.       start = Timer
  364.       For iCounter1 = 1 To txtLoopCount(0).Text
  365.           For iCounter2 = 1 To iCounter1
  366.               For iCounter3 = 1 To iCounter2
  367.                   iResult = iCounter3 * 100 + iCounter2 * 10 + iCounter1
  368.               Next iCounter3
  369.           Next iCounter2
  370.       Next iCounter1
  371.       Finish = Timer
  372.     Case 2  ' Variant 
  373.       start = Timer
  374.       For vCounter1 = 1 To txtLoopCount(1).Text
  375.           For vCounter2 = 1 To vCounter1
  376.               For vCounter3 = 1 To vCounter2
  377.                   vResult = vCounter3 * 100 + vCounter2 * 10 + vCounter1
  378.               Next vCounter3
  379.           Next vCounter2
  380.       Next vCounter1
  381.       Finish = Timer
  382.     Case 3  ' Long 
  383.       start = Timer
  384.       For lCounter1 = 1 To txtLoopCount(1).Text
  385.           For lCounter2 = 1 To lCounter1
  386.               For lCounter3 = 1 To lCounter2
  387.                   lResult = lCounter3 * 100 + lCounter2 * 10 + lCounter1
  388.               Next lCounter3
  389.           Next lCounter2
  390.       Next lCounter1
  391.       Finish = Timer
  392.     Case 4  ' Currency
  393.       start = Timer
  394.       For cCounter1 = 1 To txtLoopCount(2).Text
  395.           For cCounter2 = 1 To cCounter1
  396.               For cCounter3 = 1 To cCounter2
  397.                   cResult = (cCounter3 * 9.0123456789) + (cCounter2 * 0.001) + (cCounter1 / 0.125) - (cCounter2 * 0.001)
  398.               Next cCounter3
  399.           Next cCounter2
  400.       Next cCounter1
  401.       Finish = Timer
  402.     Case 5  ' Double
  403.       start = Timer
  404.       For dCounter1 = 1 To txtLoopCount(2).Text
  405.           For dCounter2 = 1 To dCounter1
  406.               For dCounter3 = 1 To dCounter2
  407.                   ' dResult = dCounter3 * 9.0123456789 + dCounter2 * 0.001 + dCounter1 / 0.125
  408.                   cResult = (dCounter3 * 9.0123456789) + (dCounter2 * 0.001) + (dCounter1 / 0.125) - (dCounter2 * 0.001)
  409.               Next dCounter3
  410.           Next dCounter2
  411.       Next dCounter1
  412.       Finish = Timer
  413.   End Select
  414.   lblResult(Index).Caption = Format$(Finish - start, "00.00") & " 
  415.   Screen.MousePointer = vbDefault
  416.   Exit Sub
  417. cmd_Error:
  418.   Screen.MousePointer = vbDefault
  419.   MsgBox "
  420.  " & Str$(Err) & ".  " & Error$ & vbCrLf & "
  421. ", vbExclamation, "
  422.   Exit Sub
  423. End Sub
  424. Private Sub Form_Load()
  425.   PosForm Me
  426. End Sub
  427.