Spacedinosaur
Dec 15th, 2000, 08:45 PM
I am new to writing these axctive x controls but I thought it would be a good skill to learn. I took the Karl Moore tutorial and now I am trying to write my own. It is a dice control which I know has been written before my big prob is that when I try to run this control in a project it opens up in internet explorer what am I doing wrong. Thanxs for any help
code
Option Explicit
Dim intDiceRoll As Integer
Dim m_roll As Roll
'Property Variables:
Dim m_def_roll
'Event Declarations:
Public Event Click() 'MappingInfo=UserControl,UserControl,-1,Click
Public Event ReadProperties(PropBag As PropertyBag)
Public Event WriteProperties(PropBag As PropertyBag)
Public Enum Roll
Random
One
Two
Three
Four
Five
Six
End Enum
Private Sub UserControl_Click()
RaiseEvent Click
intDiceRoll = Int(Rnd * 6) + 1
Roll_Die
End Sub
Private Sub Roll_Die()
Dim intValue As Integer
Select Case intDiceRoll
Case 1
shpOne.Visible = False
shpTwo.Visible = False
shpThree.Visible = False
shpfour.Visible = True
shpFive.Visible = False
shpsix.Visible = False
shpSeven.Visible = False
intValue = 1
Case 2
shpOne.Visible = True
shpTwo.Visible = False
shpThree.Visible = False
shpfour.Visible = False
shpFive.Visible = False
shpsix.Visible = False
shpSeven.Visible = True
intValue = 2
Case 3
shpOne.Visible = True
shpTwo.Visible = False
shpThree.Visible = False
shpfour.Visible = True
shpFive.Visible = False
shpsix.Visible = False
shpSeven.Visible = True
intValue = 3
Case 4
shpOne.Visible = True
shpTwo.Visible = True
shpThree.Visible = False
shpfour.Visible = False
shpFive.Visible = False
shpsix.Visible = True
shpSeven.Visible = True
intValue = 4
Case 5
shpOne.Visible = True
shpTwo.Visible = True
shpThree.Visible = False
shpfour.Visible = True
shpFive.Visible = False
shpsix.Visible = True
shpSeven.Visible = True
intValue = 5
Case 6
shpOne.Visible = True
shpTwo.Visible = True
shpThree.Visible = True
shpfour.Visible = False
shpFive.Visible = True
shpsix.Visible = True
shpSeven.Visible = True
intValue = 6
End Select
End Sub
Private Sub UserControl_Resize()
With shpDice
.Height = UserControl.ScaleHeight
.Top = UserControl.ScaleTop
.Left = UserControl.ScaleLeft
.Width = UserControl.ScaleWidth
End With
End Sub
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=14,0,0,0
Public Property Get Roll() As Roll
Roll = m_roll
End Property
Public Property Let Roll(ByVal New_Roll As Roll)
m_roll = New_Roll
If m_roll = Random Then
m_roll = Int(Rnd * 6) + 1
End If
intDiceRoll = m_roll
Roll_Die
PropertyChanged "Roll"
End Property
'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
m_def_roll = intDiceRoll
m_roll = m_def_roll
End Sub
'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
m_roll = PropBag.ReadProperty("Roll", m_roll)
End Sub
'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Roll", m_roll, m_roll)
End Sub
code
Option Explicit
Dim intDiceRoll As Integer
Dim m_roll As Roll
'Property Variables:
Dim m_def_roll
'Event Declarations:
Public Event Click() 'MappingInfo=UserControl,UserControl,-1,Click
Public Event ReadProperties(PropBag As PropertyBag)
Public Event WriteProperties(PropBag As PropertyBag)
Public Enum Roll
Random
One
Two
Three
Four
Five
Six
End Enum
Private Sub UserControl_Click()
RaiseEvent Click
intDiceRoll = Int(Rnd * 6) + 1
Roll_Die
End Sub
Private Sub Roll_Die()
Dim intValue As Integer
Select Case intDiceRoll
Case 1
shpOne.Visible = False
shpTwo.Visible = False
shpThree.Visible = False
shpfour.Visible = True
shpFive.Visible = False
shpsix.Visible = False
shpSeven.Visible = False
intValue = 1
Case 2
shpOne.Visible = True
shpTwo.Visible = False
shpThree.Visible = False
shpfour.Visible = False
shpFive.Visible = False
shpsix.Visible = False
shpSeven.Visible = True
intValue = 2
Case 3
shpOne.Visible = True
shpTwo.Visible = False
shpThree.Visible = False
shpfour.Visible = True
shpFive.Visible = False
shpsix.Visible = False
shpSeven.Visible = True
intValue = 3
Case 4
shpOne.Visible = True
shpTwo.Visible = True
shpThree.Visible = False
shpfour.Visible = False
shpFive.Visible = False
shpsix.Visible = True
shpSeven.Visible = True
intValue = 4
Case 5
shpOne.Visible = True
shpTwo.Visible = True
shpThree.Visible = False
shpfour.Visible = True
shpFive.Visible = False
shpsix.Visible = True
shpSeven.Visible = True
intValue = 5
Case 6
shpOne.Visible = True
shpTwo.Visible = True
shpThree.Visible = True
shpfour.Visible = False
shpFive.Visible = True
shpsix.Visible = True
shpSeven.Visible = True
intValue = 6
End Select
End Sub
Private Sub UserControl_Resize()
With shpDice
.Height = UserControl.ScaleHeight
.Top = UserControl.ScaleTop
.Left = UserControl.ScaleLeft
.Width = UserControl.ScaleWidth
End With
End Sub
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MemberInfo=14,0,0,0
Public Property Get Roll() As Roll
Roll = m_roll
End Property
Public Property Let Roll(ByVal New_Roll As Roll)
m_roll = New_Roll
If m_roll = Random Then
m_roll = Int(Rnd * 6) + 1
End If
intDiceRoll = m_roll
Roll_Die
PropertyChanged "Roll"
End Property
'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
m_def_roll = intDiceRoll
m_roll = m_def_roll
End Sub
'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
m_roll = PropBag.ReadProperty("Roll", m_roll)
End Sub
'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Roll", m_roll, m_roll)
End Sub