
Originally Posted by
jmcilhinney
I think you want something like this:
Public myColor As New Color_Class(Me)
Thanks for the fast answer. What's the significance of (Me) in that declaration?
I have to say though, from the example that you've provided I can't see any advantage to defining a nested class over just putting that behaviour in the control itself.
Well, I'm probably mis-guided, but I like the idea of a class that contains many sub-classes.
Like:
vb.net Code:
Class Machine
Public Name As String
Class Modes
Private _currentMode as Byte
Public Const OFF as Byte = 0
Public Const ON as Byte = 1
Public Const Standby as Byte = 2
Property Mode() as byte
Get
Mode = _currentMode
End Get
Set(ByVal value as byte)
If value >=0 and value <=2 Then
_currentMode = value
End If
End Property
Sub ChangeMode()
Machine.Operate(_currentMode)
End Sub
End Class
End Class
.
.
.
Public myMachine as new Machine
myMachine.Name = "Herbert"
myMachine.Mode = myMachine.Modes.ON
myMachine.Mode.ChangeMode
I guess you're suggesting that I don't bother?