I trying to create my own class in class model in Excel. It is a code :
Private cshort_name As String
Private crevenue As Double
Private crevard As Double
Private cmarja As Double
Private ctrading As Integer
Private cshort As Integer
Private ccode As String
Private cweigth As Double
Private cdiver As Integer
Private cprice As Double
Private cprice_1 As Double
Private cprice_2 As Double
Private crest As Integer
Private cmax_pos As Double
Private crest_limit As Double
Public Property Get short_name() As String
short_name = cshort_name
End Property
Public Property Let cshort_name(Value As String)
cshort_name = Value
End Property
Public Property Get revenue() As Double
revenue = crevenue
End Property
Public Property Let revenue(Value As Double)
crevenue = revenue
End Property
Public Property Get revard() As Double
revard = crevard
End Property
Public Property Let crevard(Value As Double)
If Value >= 0 Or Value <= 1 Then
crevard = Value
Else
messagebox ("Польза может быть только больше 0 и меньше 1")
crevard = 0
End If
End Property
Public Property Get marja() As Double
marja = cmarja
End Property
Public Property Let cmarja(Value As Double)
If Value >= 0 Or Value <= 1 Then
cmarja = Value
Else
messagebox ("Маржа может быть только больше 0 и меньше 1")
cmarja = 0
End If
End Property
Public Property Get trading() As Integer
trading = ctrading
End Property
Public Property Let ctrading(Value As Integer)
If Value = 0 Or Value = 1 Then
ctrading = Value
Else
messagebox ("Флаг может принимать либо значение 0 либо 1")
ctrading = 0
End If
End Property
Public Property Get short() As Integer
short = cshort
End Property
Public Property Let cshort(Value As Integer)
If Value = 0 Or Value = 1 Then
cshort = Value
Else
messagebox ("Флаг может принимать либо значение 0 либо 1")
cshort = 0
End If
End Property
Public Property Get code() As String
code = ccode
End Property
Public Property Let ccode(Value As String)
ccode = Value
End Property
Public Property Get weigth() As Double
weigth = cweigth
End Property
Public Property Let cweigth(Value As Double)
If Value < 1 Then
messagebox ("Диверсификация не может быть меньше 1")
cweigth = 1
Else
cweigth = Value
End If
End Property
Public Property Get price() As Double
price = cprice
End Property
Public Property Let cprice(Value As Double)
cprice = Value
End Property
Public Property Get price_1() As Double
price_1 = cprice_1
End Property
Public Property Let cprice_1(Value As Double)
cprice_1 = Value
End Property
Public Property Get price_2() As Double
price_ = cprice_
End Property
Public Property Let cprice_2(Value As Double)
cprice_2 = Value
End Property
And after i trying to create an instance of this class using button
Private Sub CommandButton1_Click()
Dim stock As Class1
Set stock = New Class1
End Sub
But then i press the button this message has occured :
http://s54.radikal.ru/i146/0912/fa/25a9b043faff.jpg
Bookmarks