G
Greg Maxey
I am trying to create and object and then create/define a property of that
object. My homework is to make sense of something like this'
Public MyStupidIdea as SomeObjectType
Sub Test()
Set MyStupidIdea = New SomeObjectType
MyStupidIdea.MyPointlessProperty = Something
MsgBox myStupidIdea.MyPointlessProperty
End Sub
Don't laugh, my Sensei is always deadly serious ;-)
The idea of a user defined object really shivers my timbers. I don't have
much experience with them. The only thing I have used is a Class module
with Property Get and Let statements. So I proceded as follows:
I created a new Class Module and named it myObject
In the class module I used the following code:
Option Explicit
Private mTag As String
Public Property Get Tag() As String
Tag = mTag
End Property
Public Property Let Tag(NewValue As String)
mTag = NewValue
End Property
In the project module I used the following code:
Public frmObject As MyObject
Sub Test()
Set frmObject = New MyObject
frmObject.Tag = "Almost there!!"
MsgBox frmObject.Tag
Set frmObject = Nothing
End Sub
This works. My question is do I have to use a class module to create a user
defined object? Is there some generic object in Word that I could use to
set property values for easy use? Something like:
Dim myObject as GenericObject
Set myObject = New GenericObject
myOject.Name = "Greg"
MsgBox myObject.Name
Set myObject = Nothin
Is there a easier or simpler way rather than the Class module?
Thanks.
object. My homework is to make sense of something like this'
Public MyStupidIdea as SomeObjectType
Sub Test()
Set MyStupidIdea = New SomeObjectType
MyStupidIdea.MyPointlessProperty = Something
MsgBox myStupidIdea.MyPointlessProperty
End Sub
Don't laugh, my Sensei is always deadly serious ;-)
The idea of a user defined object really shivers my timbers. I don't have
much experience with them. The only thing I have used is a Class module
with Property Get and Let statements. So I proceded as follows:
I created a new Class Module and named it myObject
In the class module I used the following code:
Option Explicit
Private mTag As String
Public Property Get Tag() As String
Tag = mTag
End Property
Public Property Let Tag(NewValue As String)
mTag = NewValue
End Property
In the project module I used the following code:
Public frmObject As MyObject
Sub Test()
Set frmObject = New MyObject
frmObject.Tag = "Almost there!!"
MsgBox frmObject.Tag
Set frmObject = Nothing
End Sub
This works. My question is do I have to use a class module to create a user
defined object? Is there some generic object in Word that I could use to
set property values for easy use? Something like:
Dim myObject as GenericObject
Set myObject = New GenericObject
myOject.Name = "Greg"
MsgBox myObject.Name
Set myObject = Nothin
Is there a easier or simpler way rather than the Class module?
Thanks.