home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Windows 95 Special 2 / WIN95_2.bin / utils / envelop / envelop.6 / Tools / Bootcamp / basic / gauge / gauge.eto < prev    next >
Encoding:
Text File  |  1996-07-08  |  10.1 KB  |  393 lines

  1. Type GaugeMasterForm From SampleMasterForm
  2.   Dim Gauge1 As New Gauge
  3.   Dim Gauge2 As New Gauge
  4.   Dim Gauge3 As New Gauge
  5.   Dim Gauge4 As New Gauge
  6.   Dim Gauge5 As New Gauge
  7.   Dim Gauge6 As New Gauge
  8.   Dim Gauge7 As New Gauge
  9.   Dim Gauge8 As New Gauge
  10.   Dim Gauge9 As New Gauge
  11.   Dim Gauge10 As New Gauge
  12.   Dim Gauge11 As New Gauge
  13.   Dim btnClear As New Button
  14.   Dim btnRoll As New Button
  15.   Dim Label1 As New Label
  16.   Dim lblNumberRolls As New Label
  17.   Dim Label3 As New Label
  18.   Dim lblGaugeMax As New Label
  19.   Dim Label5 As New Label
  20.   Dim lblRollsPerTurn As New Label
  21.   Dim sbrGaugeMax As New ScrollBar
  22.   Dim sbrRolls As New ScrollBar
  23.   Dim Label7 As New Label
  24.   Dim Label8 As New Label
  25.   Dim Label9 As New Label
  26.   Property NumRolls Get getNumRolls Set setNumRolls As Integer
  27.   Property MaxValue Get getMaxValue Set setMaxValue As Integer
  28.   Property RollCounter Get getRollCounter Set setRollCounter As Integer
  29.  
  30.   ' METHODS for object: GaugeMasterForm
  31.   Sub btnClear_Click()
  32.     ' Reset the roll count to 0. Because roll count is
  33.     ' a procedural property this will reset the gauges.
  34.     RollCounter = 0
  35.   End Sub
  36.  
  37.   Sub btnRoll_Click()
  38.     Dim i, r as integer
  39.     Dim gauge As Gauge
  40.   
  41.     ' Disable the roll button to prevent excessive clicks
  42.     btnRoll.Enabled = "False"
  43.   
  44.     For i = 1 To NumRolls
  45.       r = RollDice(1, 6, 2)
  46.       Select Case r
  47.         Case 2
  48.           gauge = Gauge1
  49.         Case 3
  50.           gauge = Gauge2
  51.         Case 4
  52.           gauge = Gauge3
  53.         Case 5
  54.           gauge = Gauge4
  55.         Case 6
  56.           gauge = Gauge5
  57.         Case 7
  58.           gauge = Gauge6
  59.         Case 8
  60.           gauge = Gauge7
  61.         Case 9
  62.           gauge = Gauge8
  63.         Case 10
  64.           gauge = Gauge9
  65.         Case 11
  66.           gauge = Gauge10
  67.         Case 12
  68.           gauge = Gauge11
  69.       End Select
  70.   
  71.       ' Increment the gauge and the counter
  72.       gauge.Value = gauge.Value + 1
  73.       RollCounter = RollCounter + 1
  74.     Next i
  75.     btnRoll.Enabled = "True"
  76.   
  77.   End Sub
  78.  
  79.   Function getMaxValue() As Integer
  80.     ' Use the scroll bars value to represent the max value
  81.     getMaxValue = sbrGaugeMax.Value
  82.   End Function
  83.  
  84.   Function getNumRolls() As Integer
  85.     ' Use the scroll bar's value as the number of rolls
  86.     getNumRolls = sbrRolls.Value
  87.   End Function
  88.  
  89.   Function getRollCounter() As Integer
  90.     ' Use the label's text to store the value for
  91.     ' the roll counter. This require's a conversion, which
  92.     ' is performed implicitly
  93.     getRollCounter = lblNumberRolls.Text
  94.   End Function
  95.  
  96.   Sub ResetApplication_Click ()
  97.   
  98.     ' Initialize gauge and roll values
  99.     MaxValue = 20
  100.     NumRolls = 10
  101.     RollCounter = 0
  102.   
  103.     ' Activate the buttons
  104.     btnRoll.Enabled = "True"
  105.   
  106.   End Sub
  107.  
  108.   Function RollDice(low As Integer, high As Integer, n As Integer) As Integer
  109.     Dim range, sum, i As Integer
  110.     range = high - low + 1
  111.     sum = 0
  112.   
  113.     For i = 1 To n
  114.       sum = sum + rnd() * range + low
  115.     Next i
  116.   
  117.     RollDice = sum
  118.   End Function
  119.  
  120.   Sub sbrGaugeMax_Change()
  121.     ' Update the maximum gauge value for all gauges
  122.     MaxValue = sbrGaugeMax.Value
  123.   End Sub
  124.  
  125.   Sub sbrGaugeMax_Scroll()
  126.     ' Update the maximum gauge value for all gauges
  127.     MaxValue = sbrGaugeMax.Value
  128.   
  129.   End Sub
  130.  
  131.   Sub sbrRolls_Change()
  132.     ' Update the NumRolls embedded integer and the rolls per turn text
  133.     NumRolls = sbrRolls.Value
  134.   End Sub
  135.  
  136.   Sub sbrRolls_Scroll()
  137.     ' Update the number of rolls per turn
  138.     NumRolls = sbrRolls.Value
  139.   End Sub
  140.  
  141.   Sub setMaxValue(v as Integer)
  142.   
  143.     lblGaugeMax.Text = v
  144.     sbrGaugeMax.Value = v
  145.   
  146.     ' Initialize maximum values for gauges
  147.     Gauge1.Max = v
  148.     Gauge2.Max = v
  149.     Gauge3.Max = v
  150.     Gauge4.Max = v
  151.     Gauge5.Max = v
  152.     Gauge6.Max = v
  153.     Gauge7.Max = v
  154.     Gauge8.Max = v
  155.     Gauge9.Max = v
  156.     Gauge10.Max = v
  157.     Gauge11.Max = v
  158.   
  159.   End Sub
  160.  
  161.   Sub setNumRolls(r as integer)
  162.     lblRollsPerTurn.Text = r
  163.     sbrRolls.Value = r
  164.   End Sub
  165.  
  166.   Sub setRollCounter(c as Integer)
  167.     ' Whenver the count is set to 0 (or less), treat it as 0
  168.     ' and clear out the gauges
  169.     If c <= 0 Then 
  170.       c = 0
  171.       Gauge1.Value = 0
  172.       Gauge2.Value = 0
  173.       Gauge3.Value = 0
  174.       Gauge4.Value = 0
  175.       Gauge5.Value = 0
  176.       Gauge6.Value = 0
  177.       Gauge7.Value = 0
  178.       Gauge8.Value = 0
  179.       Gauge9.Value = 0
  180.       Gauge10.Value = 0
  181.       Gauge11.Value = 0
  182.     End If
  183.   
  184.     ' Use the label's text as the storage for the count
  185.     lblNumberRolls.Text = c
  186.   
  187.   End Sub
  188.  
  189. End Type
  190.  
  191. Begin Code
  192. ' Reconstruction commands for object: GaugeMasterForm
  193. '
  194.   With GaugeMasterForm
  195.     .Caption := "Gauge Demonstration"
  196.     .Move(6795, 1980, 6435, 6705)
  197.     .SampleDir := "C:\ENVELOP\bootcamp\basic\gauge\"
  198.     .SampleName := "GAUGE"
  199.     .NumRolls := 86
  200.     .MaxValue := 55
  201.     .RollCounter := 60
  202.     With .Gauge1
  203.       .Caption := "2"
  204.       .ForeColor := 0
  205.       .ZOrder := 1
  206.       .Move(450, 450, 420, 2250)
  207.       .Max := 55
  208.       .Orientation := "Vertical"
  209.       .Move(450, 450, 420, 2250)
  210.     End With  'GaugeMasterForm.Gauge1
  211.     With .Gauge2
  212.       .Caption := "3"
  213.       .ForeColor := 0
  214.       .ZOrder := 2
  215.       .Move(945, 450, 420, 2250)
  216.       .Max := 55
  217.       .Value := 4
  218.       .Orientation := "Vertical"
  219.       .Move(945, 450, 420, 2250)
  220.     End With  'GaugeMasterForm.Gauge2
  221.     With .Gauge3
  222.       .Caption := "4"
  223.       .ForeColor := 0
  224.       .ZOrder := 3
  225.       .Move(1440, 450, 420, 2250)
  226.       .Max := 55
  227.       .Value := 5
  228.       .Orientation := "Vertical"
  229.       .Move(1440, 450, 420, 2250)
  230.     End With  'GaugeMasterForm.Gauge3
  231.     With .Gauge4
  232.       .Caption := "5"
  233.       .ForeColor := 0
  234.       .ZOrder := 4
  235.       .Move(1935, 450, 420, 2250)
  236.       .Max := 55
  237.       .Value := 8
  238.       .Orientation := "Vertical"
  239.       .Move(1935, 450, 420, 2250)
  240.     End With  'GaugeMasterForm.Gauge4
  241.     With .Gauge5
  242.       .Caption := "6"
  243.       .ForeColor := 0
  244.       .ZOrder := 5
  245.       .Move(2430, 450, 420, 2250)
  246.       .Max := 55
  247.       .Value := 7
  248.       .Orientation := "Vertical"
  249.       .Move(2430, 450, 420, 2250)
  250.     End With  'GaugeMasterForm.Gauge5
  251.     With .Gauge6
  252.       .Caption := "7"
  253.       .ForeColor := 0
  254.       .ZOrder := 6
  255.       .Move(2925, 450, 420, 2250)
  256.       .Max := 55
  257.       .Value := 14
  258.       .Orientation := "Vertical"
  259.       .Move(2925, 450, 420, 2250)
  260.     End With  'GaugeMasterForm.Gauge6
  261.     With .Gauge7
  262.       .Caption := "8"
  263.       .ForeColor := 0
  264.       .ZOrder := 7
  265.       .Move(3420, 450, 420, 2250)
  266.       .Max := 55
  267.       .Value := 8
  268.       .Orientation := "Vertical"
  269.       .Move(3420, 450, 420, 2250)
  270.     End With  'GaugeMasterForm.Gauge7
  271.     With .Gauge8
  272.       .Caption := "9"
  273.       .ForeColor := 0
  274.       .ZOrder := 8
  275.       .Move(3915, 450, 420, 2250)
  276.       .Max := 55
  277.       .Value := 5
  278.       .Orientation := "Vertical"
  279.       .Move(3915, 450, 420, 2250)
  280.     End With  'GaugeMasterForm.Gauge8
  281.     With .Gauge9
  282.       .Caption := "10"
  283.       .ForeColor := 0
  284.       .ZOrder := 9
  285.       .Move(4410, 450, 420, 2250)
  286.       .Max := 55
  287.       .Value := 6
  288.       .Orientation := "Vertical"
  289.       .Move(4410, 450, 420, 2250)
  290.     End With  'GaugeMasterForm.Gauge9
  291.     With .Gauge10
  292.       .Caption := "11"
  293.       .ForeColor := 0
  294.       .ZOrder := 10
  295.       .Move(4905, 450, 420, 2250)
  296.       .Max := 55
  297.       .Value := 1
  298.       .Orientation := "Vertical"
  299.       .Move(4905, 450, 420, 2250)
  300.     End With  'GaugeMasterForm.Gauge10
  301.     With .Gauge11
  302.       .Caption := "12"
  303.       .ForeColor := 0
  304.       .ZOrder := 11
  305.       .Move(5400, 450, 420, 2250)
  306.       .Max := 55
  307.       .Value := 2
  308.       .Orientation := "Vertical"
  309.       .Move(5400, 450, 420, 2250)
  310.     End With  'GaugeMasterForm.Gauge11
  311.     With .btnClear
  312.       .Caption := "Clear"
  313.       .ZOrder := 12
  314.       .Move(4800, 3000, 1050, 450)
  315.     End With  'GaugeMasterForm.btnClear
  316.     With .btnRoll
  317.       .Caption := "Roll"
  318.       .ZOrder := 13
  319.       .Move(3600, 3000, 1050, 450)
  320.     End With  'GaugeMasterForm.btnRoll
  321.     With .Label1
  322.       .Caption := "Total Number Rolls:"
  323.       .ZOrder := 14
  324.       .Move(450, 3150, 1950, 300)
  325.     End With  'GaugeMasterForm.Label1
  326.     With .lblNumberRolls
  327.       .ZOrder := 15
  328.       .Move(2550, 3150, 900, 300)
  329.     End With  'GaugeMasterForm.lblNumberRolls
  330.     With .Label3
  331.       .Caption := "Gauge Max Value:"
  332.       .ZOrder := 16
  333.       .Move(450, 3600, 1950, 300)
  334.     End With  'GaugeMasterForm.Label3
  335.     With .lblGaugeMax
  336.       .ZOrder := 17
  337.       .Move(2550, 3600, 900, 300)
  338.     End With  'GaugeMasterForm.lblGaugeMax
  339.     With .Label5
  340.       .Caption := "Rolls per turn:"
  341.       .ZOrder := 18
  342.       .Move(450, 4050, 1950, 300)
  343.     End With  'GaugeMasterForm.Label5
  344.     With .lblRollsPerTurn
  345.       .ZOrder := 19
  346.       .Move(2550, 4050, 900, 300)
  347.     End With  'GaugeMasterForm.lblRollsPerTurn
  348.     With .sbrGaugeMax
  349.       .ZOrder := 20
  350.       .Move(3600, 3600, 2250, 300)
  351.       .SmallChange := 1
  352.       .LargeChange := 10
  353.       .Min := 10
  354.       .Max := 100
  355.       .Value := 55
  356.       .Orientation := "Horizontal"
  357.       .Move(3600, 3600, 2250, 300)
  358.     End With  'GaugeMasterForm.sbrGaugeMax
  359.     With .sbrRolls
  360.       .ZOrder := 21
  361.       .Move(3600, 4050, 2250, 300)
  362.       .SmallChange := 1
  363.       .LargeChange := 10
  364.       .Min := 1
  365.       .Max := 100
  366.       .Value := 86
  367.       .Orientation := "Horizontal"
  368.       .Move(3600, 4050, 2250, 300)
  369.     End With  'GaugeMasterForm.sbrRolls
  370.     With .Label7
  371.       .Caption := "1. Click Roll button to roll (2) dice and see results above."
  372.       .ForeColor := 13107200
  373.       .ZOrder := 22
  374.       .Move(300, 4650, 5550, 300)
  375.     End With  'GaugeMasterForm.Label7
  376.     With .Label8
  377.       .Caption := "2. Adjust Gauge Max value with ScrollBar."
  378.       .ForeColor := 13107200
  379.       .ZOrder := 23
  380.       .Move(300, 5100, 4200, 300)
  381.     End With  'GaugeMasterForm.Label8
  382.     With .Label9
  383.       .Caption := "3. Adjust Rolls per turn with ScrollBar."
  384.       .ForeColor := 13107200
  385.       .ZOrder := 24
  386.       .Move(300, 5550, 4050, 300)
  387.     End With  'GaugeMasterForm.Label9
  388.     With .helpfile
  389.       .FileName := "C:\ENVELOP\bootcamp\basic\gauge\GAUGE.hlp"
  390.     End With  'GaugeMasterForm.helpfile
  391.   End With  'GaugeMasterForm
  392. End Code
  393.