Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Let/get/set or something
Message
Information générale
Forum:
Visual Basic
Catégorie:
Contrôles ActiveX
Divers
Thread ID:
00438845
Message ID:
00438935
Vues:
10
>Using VB 6 in an ActiveX EXE with a severe time crunch ...
>
>Anyone have a good example of let/get/set (or ...) What I want to do is create a a pair of class modules (or ...) and be able to access properties in the following manner:
>
>x = class1.property1
>y = class2.property1
>
>a = class1.property2
>b = class2.property2
>
>....
>Maybe, I am barking up the wrong tree and class mods are not the best way achieve this result. Any input is good input.
>
>Thanks in advance,

Using the class builder (found in the Add-ins manager) I generate this code in no-time for you!

Try this:

Option Explicit

'local variable(s) to hold property value(s)
Private mvarTargetDir As String 'local copy
Private mvarTargetFile As String 'local copy
Private mvarSourceDir As String 'local copy
Public Sub MyActionExecution()
End Sub

Public Property Let SourceDir(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.SourceDir = 5
mvarSourceDir = vData
End Property


Public Property Get SourceDir() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.SourceDir
SourceDir = mvarSourceDir
End Property



Public Property Let TargetFile(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.TargetFile = 5
mvarTargetFile = vData
End Property


Public Property Get TargetFile() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.TargetFile
TargetFile = mvarTargetFile
End Property



Public Property Let TargetDir(ByVal vData As String)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.TargetDir = 5
mvarTargetDir = vData
End Property


Public Property Get TargetDir() As String
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.TargetDir
TargetDir = mvarTargetDir
End Property

Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform