Private Public As Private s As String Private
Определение полей класса {Private | Public} <имя> As <тип> Private s As String Private n As Integer Private mas(1 To 10) As Double
Private s As String Private n As Integer Private mas(1 To 10) As Double Public Property Get Size() As Integer Size = n End Property Public Property Let Size(s As Integer) If s >= 1 And s <= 10 Then n = s Else n = 0 End If End Property
Private s As String Private n As Integer Private mas(1 To 10) As Double Public Function Get. Element(i As Integer) As Double If i >= 1 And i <= 10 Then Get. Element = mas(i) End If End Function Public Sub Set. Element(i As Integer, v As Double) If i >= 1 And i <= 10 Then mas(i) = v End If End Sub
Public Event Incorrect. Index() Private s As String Private n As Integer Private mas(1 To 10) As Double. . . Public Function Get. Element(i As Integer) As Double If i >= 1 And i <= 10 Then Get. Element = mas(i) Else Raise. Event Incorrect. Index End If End Function
Public Sub Set. Element(i As Integer, v As Double) If i >= 1 And i <= 10 Then mas(i) = v Else Raise. Event Incorrect. Index End If End Sub Public Sub Class_Initialize() n = 0 End Sub
Private x As My. Class Private Sub Test() Dim i As Integer, s As Double Set x = New My. Class x. Size = 5 'Запись свойства класса For i = 1 To x. Size 'Чтение свойства класса x. Set. Element(i, i * 0. 1) Next i s = 0 For i = 1 To x. Size s = s + x. Get. Element(i) Next i Set s = Nothing End Sub
Private With. Events x As My. Class Private Sub Test(). . . End Sub Private Sub x_Incorrect. Index(). . . End Sub
- Slides: 25