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 / ch04code / sqlcalc.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-08-15  |  16.9 KB  |  542 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "SQL - Program Comparison"
  4.    ClientHeight    =   5040
  5.    ClientLeft      =   1245
  6.    ClientTop       =   1635
  7.    ClientWidth     =   6780
  8.    BeginProperty Font 
  9.       name            =   "MS Sans Serif"
  10.       charset         =   1
  11.       weight          =   400
  12.       size            =   12
  13.       underline       =   0   'False
  14.       italic          =   0   'False
  15.       strikethrough   =   0   'False
  16.    EndProperty
  17.    Height          =   5505
  18.    Left            =   1155
  19.    LinkTopic       =   "Form1"
  20.    ScaleHeight     =   5040
  21.    ScaleWidth      =   6780
  22.    Top             =   1260
  23.    Width           =   6960
  24.    Begin VB.TextBox Text13 
  25.       Enabled         =   0   'False
  26.       BeginProperty Font 
  27.          name            =   "MS Sans Serif"
  28.          charset         =   1
  29.          weight          =   400
  30.          size            =   9.75
  31.          underline       =   0   'False
  32.          italic          =   0   'False
  33.          strikethrough   =   0   'False
  34.       EndProperty
  35.       Height          =   855
  36.       Left            =   360
  37.       MultiLine       =   -1  'True
  38.       TabIndex        =   26
  39.       Text            =   "SQLCALC.frx":0000
  40.       Top             =   120
  41.       Width           =   5895
  42.    End
  43.    Begin VB.TextBox Text12 
  44.       BeginProperty Font 
  45.          name            =   "MS Sans Serif"
  46.          charset         =   1
  47.          weight          =   400
  48.          size            =   8.25
  49.          underline       =   0   'False
  50.          italic          =   0   'False
  51.          strikethrough   =   0   'False
  52.       EndProperty
  53.       Height          =   285
  54.       Left            =   4800
  55.       TabIndex        =   25
  56.       Text            =   "Text12"
  57.       Top             =   4320
  58.       Width           =   1335
  59.    End
  60.    Begin VB.TextBox Text11 
  61.       BeginProperty Font 
  62.          name            =   "MS Sans Serif"
  63.          charset         =   1
  64.          weight          =   400
  65.          size            =   8.25
  66.          underline       =   0   'False
  67.          italic          =   0   'False
  68.          strikethrough   =   0   'False
  69.       EndProperty
  70.       Height          =   285
  71.       Left            =   1440
  72.       TabIndex        =   24
  73.       Text            =   "Text11"
  74.       Top             =   4320
  75.       Width           =   1215
  76.    End
  77.    Begin VB.CommandButton Command2 
  78.       Caption         =   "Program Calculation"
  79.       BeginProperty Font 
  80.          name            =   "MS Sans Serif"
  81.          charset         =   1
  82.          weight          =   400
  83.          size            =   8.25
  84.          underline       =   0   'False
  85.          italic          =   0   'False
  86.          strikethrough   =   0   'False
  87.       EndProperty
  88.       Height          =   375
  89.       Left            =   3600
  90.       TabIndex        =   21
  91.       Top             =   1200
  92.       Width           =   2535
  93.    End
  94.    Begin VB.CommandButton Command1 
  95.       Caption         =   "SQL Calculation"
  96.       BeginProperty Font 
  97.          name            =   "MS Sans Serif"
  98.          charset         =   1
  99.          weight          =   400
  100.          size            =   8.25
  101.          underline       =   0   'False
  102.          italic          =   0   'False
  103.          strikethrough   =   0   'False
  104.       EndProperty
  105.       Height          =   375
  106.       Left            =   360
  107.       TabIndex        =   20
  108.       Top             =   1200
  109.       Width           =   2295
  110.    End
  111.    Begin VB.TextBox Text10 
  112.       BeginProperty Font 
  113.          name            =   "MS Sans Serif"
  114.          charset         =   1
  115.          weight          =   400
  116.          size            =   8.25
  117.          underline       =   0   'False
  118.          italic          =   0   'False
  119.          strikethrough   =   0   'False
  120.       EndProperty
  121.       Height          =   285
  122.       Left            =   4800
  123.       TabIndex        =   19
  124.       Text            =   "Text10"
  125.       Top             =   3840
  126.       Width           =   1335
  127.    End
  128.    Begin VB.TextBox Text9 
  129.       BeginProperty Font 
  130.          name            =   "MS Sans Serif"
  131.          charset         =   1
  132.          weight          =   400
  133.          size            =   8.25
  134.          underline       =   0   'False
  135.          italic          =   0   'False
  136.          strikethrough   =   0   'False
  137.       EndProperty
  138.       Height          =   285
  139.       Left            =   4800
  140.       TabIndex        =   18
  141.       Text            =   "Text9"
  142.       Top             =   3360
  143.       Width           =   1335
  144.    End
  145.    Begin VB.TextBox Text8 
  146.       BeginProperty Font 
  147.          name            =   "MS Sans Serif"
  148.          charset         =   1
  149.          weight          =   400
  150.          size            =   8.25
  151.          underline       =   0   'False
  152.          italic          =   0   'False
  153.          strikethrough   =   0   'False
  154.       EndProperty
  155.       Height          =   285
  156.       Left            =   4800
  157.       TabIndex        =   17
  158.       Text            =   "Text8"
  159.       Top             =   2880
  160.       Width           =   1335
  161.    End
  162.    Begin VB.TextBox Text7 
  163.       BeginProperty Font 
  164.          name            =   "MS Sans Serif"
  165.          charset         =   1
  166.          weight          =   400
  167.          size            =   8.25
  168.          underline       =   0   'False
  169.          italic          =   0   'False
  170.          strikethrough   =   0   'False
  171.       EndProperty
  172.       Height          =   285
  173.       Left            =   4800
  174.       TabIndex        =   16
  175.       Text            =   "Text7"
  176.       Top             =   2400
  177.       Width           =   1335
  178.    End
  179.    Begin VB.TextBox Text6 
  180.       BeginProperty Font 
  181.          name            =   "MS Sans Serif"
  182.          charset         =   1
  183.          weight          =   400
  184.          size            =   8.25
  185.          underline       =   0   'False
  186.          italic          =   0   'False
  187.          strikethrough   =   0   'False
  188.       EndProperty
  189.       Height          =   285
  190.       Left            =   4800
  191.       TabIndex        =   15
  192.       Text            =   "Text6"
  193.       Top             =   1920
  194.       Width           =   1335
  195.    End
  196.    Begin VB.TextBox Text5 
  197.       BeginProperty Font 
  198.          name            =   "MS Sans Serif"
  199.          charset         =   1
  200.          weight          =   400
  201.          size            =   8.25
  202.          underline       =   0   'False
  203.          italic          =   0   'False
  204.          strikethrough   =   0   'False
  205.       EndProperty
  206.       Height          =   285
  207.       Left            =   1440
  208.       TabIndex        =   14
  209.       Text            =   "Text5"
  210.       Top             =   3840
  211.       Width           =   1215
  212.    End
  213.    Begin VB.TextBox Text4 
  214.       BeginProperty Font 
  215.          name            =   "MS Sans Serif"
  216.          charset         =   1
  217.          weight          =   400
  218.          size            =   8.25
  219.          underline       =   0   'False
  220.          italic          =   0   'False
  221.          strikethrough   =   0   'False
  222.       EndProperty
  223.       Height          =   285
  224.       Left            =   1440
  225.       TabIndex        =   13
  226.       Text            =   "Text4"
  227.       Top             =   3360
  228.       Width           =   1215
  229.    End
  230.    Begin VB.TextBox Text3 
  231.       BeginProperty Font 
  232.          name            =   "MS Sans Serif"
  233.          charset         =   1
  234.          weight          =   400
  235.          size            =   8.25
  236.          underline       =   0   'False
  237.          italic          =   0   'False
  238.          strikethrough   =   0   'False
  239.       EndProperty
  240.       Height          =   285
  241.       Left            =   1440
  242.       TabIndex        =   12
  243.       Text            =   "Text3"
  244.       Top             =   2880
  245.       Width           =   1215
  246.    End
  247.    Begin VB.TextBox Text2 
  248.       BeginProperty Font 
  249.          name            =   "MS Sans Serif"
  250.          charset         =   1
  251.          weight          =   400
  252.          size            =   8.25
  253.          underline       =   0   'False
  254.          italic          =   0   'False
  255.          strikethrough   =   0   'False
  256.       EndProperty
  257.       Height          =   285
  258.       Left            =   1440
  259.       TabIndex        =   11
  260.       Text            =   "Text2"
  261.       Top             =   2400
  262.       Width           =   1215
  263.    End
  264.    Begin VB.TextBox Text1 
  265.       BeginProperty Font 
  266.          name            =   "MS Sans Serif"
  267.          charset         =   1
  268.          weight          =   400
  269.          size            =   8.25
  270.          underline       =   0   'False
  271.          italic          =   0   'False
  272.          strikethrough   =   0   'False
  273.       EndProperty
  274.       Height          =   285
  275.       Left            =   1440
  276.       TabIndex        =   10
  277.       Text            =   "Text1"
  278.       Top             =   1920
  279.       Width           =   1215
  280.    End
  281.    Begin VB.Line Line1 
  282.       BorderWidth     =   2
  283.       X1              =   3240
  284.       X2              =   3240
  285.       Y1              =   1200
  286.       Y2              =   4800
  287.    End
  288.    Begin VB.Label Label12 
  289.       Caption         =   "Count:"
  290.       BeginProperty Font 
  291.          name            =   "MS Sans Serif"
  292.          charset         =   1
  293.          weight          =   400
  294.          size            =   8.25
  295.          underline       =   0   'False
  296.          italic          =   0   'False
  297.          strikethrough   =   0   'False
  298.       EndProperty
  299.       Height          =   255
  300.       Left            =   3720
  301.       TabIndex        =   23
  302.       Top             =   4320
  303.       Width           =   615
  304.    End
  305.    Begin VB.Label Label11 
  306.       Caption         =   "Count:"
  307.       BeginProperty Font 
  308.          name            =   "MS Sans Serif"
  309.          charset         =   1
  310.          weight          =   400
  311.          size            =   8.25
  312.          underline       =   0   'False
  313.          italic          =   0   'False
  314.          strikethrough   =   0   'False
  315.       EndProperty
  316.       Height          =   255
  317.       Left            =   360
  318.       TabIndex        =   22
  319.       Top             =   4320
  320.       Width           =   615
  321.    End
  322.    Begin VB.Label Label10 
  323.       Caption         =   "Average:"
  324.       BeginProperty Font 
  325.          name            =   "MS Sans Serif"
  326.          charset         =   1
  327.          weight          =   400
  328.          size            =   8.25
  329.          underline       =   0   'False
  330.          italic          =   0   'False
  331.          strikethrough   =   0   'False
  332.       EndProperty
  333.       Height          =   255
  334.       Left            =   3720
  335.       TabIndex        =   9
  336.       Top             =   3840
  337.       Width           =   735
  338.    End
  339.    Begin VB.Label Label9 
  340.       Caption         =   "Maximum:"
  341.       BeginProperty Font 
  342.          name            =   "MS Sans Serif"
  343.          charset         =   1
  344.          weight          =   400
  345.          size            =   8.25
  346.          underline       =   0   'False
  347.          italic          =   0   'False
  348.          strikethrough   =   0   'False
  349.       EndProperty
  350.       Height          =   255
  351.       Left            =   3720
  352.       TabIndex        =   8
  353.       Top             =   3360
  354.       Width           =   855
  355.    End
  356.    Begin VB.Label Label8 
  357.       Caption         =   "Minimum:"
  358.       BeginProperty Font 
  359.          name            =   "MS Sans Serif"
  360.          charset         =   1
  361.          weight          =   400
  362.          size            =   8.25
  363.          underline       =   0   'False
  364.          italic          =   0   'False
  365.          strikethrough   =   0   'False
  366.       EndProperty
  367.       Height          =   255
  368.       Left            =   3720
  369.       TabIndex        =   7
  370.       Top             =   2880
  371.       Width           =   735
  372.    End
  373.    Begin VB.Label Label7 
  374.       Caption         =   "Finish Time:"
  375.       BeginProperty Font 
  376.          name            =   "MS Sans Serif"
  377.          charset         =   1
  378.          weight          =   400
  379.          size            =   8.25
  380.          underline       =   0   'False
  381.          italic          =   0   'False
  382.          strikethrough   =   0   'False
  383.       EndProperty
  384.       Height          =   255
  385.       Left            =   3720
  386.       TabIndex        =   6
  387.       Top             =   2400
  388.       Width           =   975
  389.    End
  390.    Begin VB.Label Label6 
  391.       Caption         =   "Start Time:"
  392.       BeginProperty Font 
  393.          name            =   "MS Sans Serif"
  394.          charset         =   1
  395.          weight          =   400
  396.          size            =   8.25
  397.          underline       =   0   'False
  398.          italic          =   0   'False
  399.          strikethrough   =   0   'False
  400.       EndProperty
  401.       Height          =   255
  402.       Left            =   3720
  403.       TabIndex        =   5
  404.       Top             =   1920
  405.       Width           =   855
  406.    End
  407.    Begin VB.Label Label5 
  408.       Caption         =   "Average:"
  409.       BeginProperty Font 
  410.          name            =   "MS Sans Serif"
  411.          charset         =   1
  412.          weight          =   400
  413.          size            =   8.25
  414.          underline       =   0   'False
  415.          italic          =   0   'False
  416.          strikethrough   =   0   'False
  417.       EndProperty
  418.       Height          =   255
  419.       Left            =   360
  420.       TabIndex        =   4
  421.       Top             =   3840
  422.       Width           =   735
  423.    End
  424.    Begin VB.Label Label4 
  425.       Caption         =   "Maximum:"
  426.       BeginProperty Font 
  427.          name            =   "MS Sans Serif"
  428.          charset         =   1
  429.          weight          =   400
  430.          size            =   8.25
  431.          underline       =   0   'False
  432.          italic          =   0   'False
  433.          strikethrough   =   0   'False
  434.       EndProperty
  435.       Height          =   255
  436.       Left            =   360
  437.       TabIndex        =   3
  438.       Top             =   3360
  439.       Width           =   855
  440.    End
  441.    Begin VB.Label Label3 
  442.       Caption         =   "Minimum:"
  443.       BeginProperty Font 
  444.          name            =   "MS Sans Serif"
  445.          charset         =   1
  446.          weight          =   400
  447.          size            =   8.25
  448.          underline       =   0   'False
  449.          italic          =   0   'False
  450.          strikethrough   =   0   'False
  451.       EndProperty
  452.       Height          =   255
  453.       Left            =   360
  454.       TabIndex        =   2
  455.       Top             =   2880
  456.       Width           =   735
  457.    End
  458.    Begin VB.Label Label2 
  459.       Caption         =   "Finish Time:"
  460.       BeginProperty Font 
  461.          name            =   "MS Sans Serif"
  462.          charset         =   1
  463.          weight          =   400
  464.          size            =   8.25
  465.          underline       =   0   'False
  466.          italic          =   0   'False
  467.          strikethrough   =   0   'False
  468.       EndProperty
  469.       Height          =   255
  470.       Left            =   360
  471.       TabIndex        =   1
  472.       Top             =   2400
  473.       Width           =   975
  474.    End
  475.    Begin VB.Label Label1 
  476.       Caption         =   "Start Time:"
  477.       BeginProperty Font 
  478.          name            =   "MS Sans Serif"
  479.          charset         =   1
  480.          weight          =   400
  481.          size            =   8.25
  482.          underline       =   0   'False
  483.          italic          =   0   'False
  484.          strikethrough   =   0   'False
  485.       EndProperty
  486.       Height          =   255
  487.       Left            =   360
  488.       TabIndex        =   0
  489.       Top             =   1920
  490.       Width           =   855
  491.    End
  492. Attribute VB_Name = "Form1"
  493. Attribute VB_Creatable = False
  494. Attribute VB_Exposed = False
  495. Dim OldDb As DATABASE, RcSet As Recordset, OldWs As Workspace
  496. Private Sub Command1_Click()
  497.     Sqlstate = "SELECT COUNT(*) as Cntsql,MIN([Total Cost]) as Minsql,"
  498.     Sqlstate = Sqlstate + "MAX([Total Cost]) as Maxsql, AVG([Total Cost])"
  499.     Sqlstate = Sqlstate + "as Avgsql FROM Fishbuys"
  500.     Text1.TEXT = Time()
  501.     Set RcSet = OldDb.OpenRecordset(Sqlstate, dbOpenDynaset)
  502.     Text3.TEXT = RcSet("Minsql")
  503.     Text4.TEXT = RcSet("Maxsql")
  504.     Text5.TEXT = RcSet("Avgsql")
  505.     Text11.TEXT = RcSet("Cntsql")
  506.     Text2.TEXT = Time()
  507.     RcSet.Close
  508. End Sub
  509. Private Sub Command2_Click()
  510.     Text6.TEXT = Time()
  511.     Set RcSet = OldDb.OpenRecordset("Fishbuys", dbOpenTable)
  512.     RcSet.MoveFirst
  513.     Mmcnt = 1
  514.     Sumprg = RcSet("Total Cost")
  515.     Minprg = RcSet("Total Cost")
  516.     Maxprg = RcSet("Total Cost")
  517.     Do While Not RcSet.EOF
  518.         RcSet.MoveNext
  519.         If RcSet.EOF Then
  520.             Exit Do
  521.         End If
  522.         Sumprg = Sumprg + RcSet("Total Cost")
  523.         Mmcnt = Mmcnt + 1
  524.         If RcSet("Total Cost") < Minprg Then
  525.             Minprg = RcSet("Total Cost")
  526.         End If
  527.         If RcSet("Total Cost") > Maxprg Then
  528.             Maxprg = RcSet("Total Cost")
  529.         End If
  530.     Loop
  531.     Text8.TEXT = Minprg
  532.     Text9.TEXT = Maxprg
  533.     Text10.TEXT = Sumprg / Mmcnt
  534.     Text12.TEXT = Mmcnt
  535.     Text7.TEXT = Time()
  536.     RcSet.Close
  537. End Sub
  538. Private Sub Form_Load()
  539.     Set OldWs = DBEngine.Workspaces(0)
  540.     Set OldDb = OldWs.OpenDatabase(App.Path & "\CHAPTER4.MDB")
  541. End Sub
  542.