If there is only one instance of the sound class, then you need not use a class for it. A standard module would provide all the functionality you seek, while consuming fewer resources. For example, in a module you might have:
Then, from anywhere in your application, a sound could be played like:Code:Option Explicit Public Enum Sounds Sound1 Sound2 Sound3 Sound4 End Enum Public Sub Play(Sound As Sounds) 'Play the sound End Sub
You can also use a unique name for the Public Sub, in which case there'd be no need to specify the module name.Code:Module1.Play Sound3
If you use a class for the sound, then you'd use it this way:
If you want a sound class to be within a game class, then it could work like this:Code:Dim S As clsSound Set S = New clsSound S.Play Sound3 Set S = Nothing
Yet another way to do it, the syntax would more closely resemble what you've been asking:Code:Dim G As clsGame Set G = New clsGame G.Sound.Play Sound3
In your sound class:
In your game class:Code:Public Sub Play() 'Play the sound End Sub
Then you'd use it like:Code:Public Enum Sounds Sound1 Sound2 Sound3 Sound4 End Enum Public Function Sound(S As Sounds) As clsSound Set Sound = New clsSound End Function
Code:Dim G As clsGame Set G = New clsGame G.Sound(Sound3).Play




Reply With Quote