home *** CD-ROM | disk | FTP | other *** search
- Type GaugeMasterForm From SampleMasterForm
- Dim Gauge1 As New Gauge
- Dim Gauge2 As New Gauge
- Dim Gauge3 As New Gauge
- Dim Gauge4 As New Gauge
- Dim Gauge5 As New Gauge
- Dim Gauge6 As New Gauge
- Dim Gauge7 As New Gauge
- Dim Gauge8 As New Gauge
- Dim Gauge9 As New Gauge
- Dim Gauge10 As New Gauge
- Dim Gauge11 As New Gauge
- Dim btnClear As New Button
- Dim btnRoll As New Button
- Dim Label1 As New Label
- Dim lblNumberRolls As New Label
- Dim Label3 As New Label
- Dim lblGaugeMax As New Label
- Dim Label5 As New Label
- Dim lblRollsPerTurn As New Label
- Dim sbrGaugeMax As New ScrollBar
- Dim sbrRolls As New ScrollBar
- Dim Label7 As New Label
- Dim Label8 As New Label
- Dim Label9 As New Label
- Property NumRolls Get getNumRolls Set setNumRolls As Integer
- Property MaxValue Get getMaxValue Set setMaxValue As Integer
- Property RollCounter Get getRollCounter Set setRollCounter As Integer
-
- ' METHODS for object: GaugeMasterForm
- Sub btnClear_Click()
- ' Reset the roll count to 0. Because roll count is
- ' a procedural property this will reset the gauges.
- RollCounter = 0
- End Sub
-
- Sub btnRoll_Click()
- Dim i, r as integer
- Dim gauge As Gauge
-
- ' Disable the roll button to prevent excessive clicks
- btnRoll.Enabled = "False"
-
- For i = 1 To NumRolls
- r = RollDice(1, 6, 2)
- Select Case r
- Case 2
- gauge = Gauge1
- Case 3
- gauge = Gauge2
- Case 4
- gauge = Gauge3
- Case 5
- gauge = Gauge4
- Case 6
- gauge = Gauge5
- Case 7
- gauge = Gauge6
- Case 8
- gauge = Gauge7
- Case 9
- gauge = Gauge8
- Case 10
- gauge = Gauge9
- Case 11
- gauge = Gauge10
- Case 12
- gauge = Gauge11
- End Select
-
- ' Increment the gauge and the counter
- gauge.Value = gauge.Value + 1
- RollCounter = RollCounter + 1
- Next i
- btnRoll.Enabled = "True"
-
- End Sub
-
- Function getMaxValue() As Integer
- ' Use the scroll bars value to represent the max value
- getMaxValue = sbrGaugeMax.Value
- End Function
-
- Function getNumRolls() As Integer
- ' Use the scroll bar's value as the number of rolls
- getNumRolls = sbrRolls.Value
- End Function
-
- Function getRollCounter() As Integer
- ' Use the label's text to store the value for
- ' the roll counter. This require's a conversion, which
- ' is performed implicitly
- getRollCounter = lblNumberRolls.Text
- End Function
-
- Sub ResetApplication_Click ()
-
- ' Initialize gauge and roll values
- MaxValue = 20
- NumRolls = 10
- RollCounter = 0
-
- ' Activate the buttons
- btnRoll.Enabled = "True"
-
- End Sub
-
- Function RollDice(low As Integer, high As Integer, n As Integer) As Integer
- Dim range, sum, i As Integer
- range = high - low + 1
- sum = 0
-
- For i = 1 To n
- sum = sum + rnd() * range + low
- Next i
-
- RollDice = sum
- End Function
-
- Sub sbrGaugeMax_Change()
- ' Update the maximum gauge value for all gauges
- MaxValue = sbrGaugeMax.Value
- End Sub
-
- Sub sbrGaugeMax_Scroll()
- ' Update the maximum gauge value for all gauges
- MaxValue = sbrGaugeMax.Value
-
- End Sub
-
- Sub sbrRolls_Change()
- ' Update the NumRolls embedded integer and the rolls per turn text
- NumRolls = sbrRolls.Value
- End Sub
-
- Sub sbrRolls_Scroll()
- ' Update the number of rolls per turn
- NumRolls = sbrRolls.Value
- End Sub
-
- Sub setMaxValue(v as Integer)
-
- lblGaugeMax.Text = v
- sbrGaugeMax.Value = v
-
- ' Initialize maximum values for gauges
- Gauge1.Max = v
- Gauge2.Max = v
- Gauge3.Max = v
- Gauge4.Max = v
- Gauge5.Max = v
- Gauge6.Max = v
- Gauge7.Max = v
- Gauge8.Max = v
- Gauge9.Max = v
- Gauge10.Max = v
- Gauge11.Max = v
-
- End Sub
-
- Sub setNumRolls(r as integer)
- lblRollsPerTurn.Text = r
- sbrRolls.Value = r
- End Sub
-
- Sub setRollCounter(c as Integer)
- ' Whenver the count is set to 0 (or less), treat it as 0
- ' and clear out the gauges
- If c <= 0 Then
- c = 0
- Gauge1.Value = 0
- Gauge2.Value = 0
- Gauge3.Value = 0
- Gauge4.Value = 0
- Gauge5.Value = 0
- Gauge6.Value = 0
- Gauge7.Value = 0
- Gauge8.Value = 0
- Gauge9.Value = 0
- Gauge10.Value = 0
- Gauge11.Value = 0
- End If
-
- ' Use the label's text as the storage for the count
- lblNumberRolls.Text = c
-
- End Sub
-
- End Type
-
- Begin Code
- ' Reconstruction commands for object: GaugeMasterForm
- '
- With GaugeMasterForm
- .Caption := "Gauge Demonstration"
- .Move(6795, 1980, 6435, 6705)
- .SampleDir := "C:\ENVELOP\bootcamp\basic\gauge\"
- .SampleName := "GAUGE"
- .NumRolls := 86
- .MaxValue := 55
- .RollCounter := 60
- With .Gauge1
- .Caption := "2"
- .ForeColor := 0
- .ZOrder := 1
- .Move(450, 450, 420, 2250)
- .Max := 55
- .Orientation := "Vertical"
- .Move(450, 450, 420, 2250)
- End With 'GaugeMasterForm.Gauge1
- With .Gauge2
- .Caption := "3"
- .ForeColor := 0
- .ZOrder := 2
- .Move(945, 450, 420, 2250)
- .Max := 55
- .Value := 4
- .Orientation := "Vertical"
- .Move(945, 450, 420, 2250)
- End With 'GaugeMasterForm.Gauge2
- With .Gauge3
- .Caption := "4"
- .ForeColor := 0
- .ZOrder := 3
- .Move(1440, 450, 420, 2250)
- .Max := 55
- .Value := 5
- .Orientation := "Vertical"
- .Move(1440, 450, 420, 2250)
- End With 'GaugeMasterForm.Gauge3
- With .Gauge4
- .Caption := "5"
- .ForeColor := 0
- .ZOrder := 4
- .Move(1935, 450, 420, 2250)
- .Max := 55
- .Value := 8
- .Orientation := "Vertical"
- .Move(1935, 450, 420, 2250)
- End With 'GaugeMasterForm.Gauge4
- With .Gauge5
- .Caption := "6"
- .ForeColor := 0
- .ZOrder := 5
- .Move(2430, 450, 420, 2250)
- .Max := 55
- .Value := 7
- .Orientation := "Vertical"
- .Move(2430, 450, 420, 2250)
- End With 'GaugeMasterForm.Gauge5
- With .Gauge6
- .Caption := "7"
- .ForeColor := 0
- .ZOrder := 6
- .Move(2925, 450, 420, 2250)
- .Max := 55
- .Value := 14
- .Orientation := "Vertical"
- .Move(2925, 450, 420, 2250)
- End With 'GaugeMasterForm.Gauge6
- With .Gauge7
- .Caption := "8"
- .ForeColor := 0
- .ZOrder := 7
- .Move(3420, 450, 420, 2250)
- .Max := 55
- .Value := 8
- .Orientation := "Vertical"
- .Move(3420, 450, 420, 2250)
- End With 'GaugeMasterForm.Gauge7
- With .Gauge8
- .Caption := "9"
- .ForeColor := 0
- .ZOrder := 8
- .Move(3915, 450, 420, 2250)
- .Max := 55
- .Value := 5
- .Orientation := "Vertical"
- .Move(3915, 450, 420, 2250)
- End With 'GaugeMasterForm.Gauge8
- With .Gauge9
- .Caption := "10"
- .ForeColor := 0
- .ZOrder := 9
- .Move(4410, 450, 420, 2250)
- .Max := 55
- .Value := 6
- .Orientation := "Vertical"
- .Move(4410, 450, 420, 2250)
- End With 'GaugeMasterForm.Gauge9
- With .Gauge10
- .Caption := "11"
- .ForeColor := 0
- .ZOrder := 10
- .Move(4905, 450, 420, 2250)
- .Max := 55
- .Value := 1
- .Orientation := "Vertical"
- .Move(4905, 450, 420, 2250)
- End With 'GaugeMasterForm.Gauge10
- With .Gauge11
- .Caption := "12"
- .ForeColor := 0
- .ZOrder := 11
- .Move(5400, 450, 420, 2250)
- .Max := 55
- .Value := 2
- .Orientation := "Vertical"
- .Move(5400, 450, 420, 2250)
- End With 'GaugeMasterForm.Gauge11
- With .btnClear
- .Caption := "Clear"
- .ZOrder := 12
- .Move(4800, 3000, 1050, 450)
- End With 'GaugeMasterForm.btnClear
- With .btnRoll
- .Caption := "Roll"
- .ZOrder := 13
- .Move(3600, 3000, 1050, 450)
- End With 'GaugeMasterForm.btnRoll
- With .Label1
- .Caption := "Total Number Rolls:"
- .ZOrder := 14
- .Move(450, 3150, 1950, 300)
- End With 'GaugeMasterForm.Label1
- With .lblNumberRolls
- .ZOrder := 15
- .Move(2550, 3150, 900, 300)
- End With 'GaugeMasterForm.lblNumberRolls
- With .Label3
- .Caption := "Gauge Max Value:"
- .ZOrder := 16
- .Move(450, 3600, 1950, 300)
- End With 'GaugeMasterForm.Label3
- With .lblGaugeMax
- .ZOrder := 17
- .Move(2550, 3600, 900, 300)
- End With 'GaugeMasterForm.lblGaugeMax
- With .Label5
- .Caption := "Rolls per turn:"
- .ZOrder := 18
- .Move(450, 4050, 1950, 300)
- End With 'GaugeMasterForm.Label5
- With .lblRollsPerTurn
- .ZOrder := 19
- .Move(2550, 4050, 900, 300)
- End With 'GaugeMasterForm.lblRollsPerTurn
- With .sbrGaugeMax
- .ZOrder := 20
- .Move(3600, 3600, 2250, 300)
- .SmallChange := 1
- .LargeChange := 10
- .Min := 10
- .Max := 100
- .Value := 55
- .Orientation := "Horizontal"
- .Move(3600, 3600, 2250, 300)
- End With 'GaugeMasterForm.sbrGaugeMax
- With .sbrRolls
- .ZOrder := 21
- .Move(3600, 4050, 2250, 300)
- .SmallChange := 1
- .LargeChange := 10
- .Min := 1
- .Max := 100
- .Value := 86
- .Orientation := "Horizontal"
- .Move(3600, 4050, 2250, 300)
- End With 'GaugeMasterForm.sbrRolls
- With .Label7
- .Caption := "1. Click Roll button to roll (2) dice and see results above."
- .ForeColor := 13107200
- .ZOrder := 22
- .Move(300, 4650, 5550, 300)
- End With 'GaugeMasterForm.Label7
- With .Label8
- .Caption := "2. Adjust Gauge Max value with ScrollBar."
- .ForeColor := 13107200
- .ZOrder := 23
- .Move(300, 5100, 4200, 300)
- End With 'GaugeMasterForm.Label8
- With .Label9
- .Caption := "3. Adjust Rolls per turn with ScrollBar."
- .ForeColor := 13107200
- .ZOrder := 24
- .Move(300, 5550, 4050, 300)
- End With 'GaugeMasterForm.Label9
- With .helpfile
- .FileName := "C:\ENVELOP\bootcamp\basic\gauge\GAUGE.hlp"
- End With 'GaugeMasterForm.helpfile
- End With 'GaugeMasterForm
- End Code
-