I
Ian Stanborough
My problem is that I am trying to create a reference to an object and pass
that objects address in a subroutine called examineData, which should
produce a msgbox detailing the information placed in the object "person".
I believe I am passing a reference address to my object I created in
subroutine testReference, to the subroutine examineData. But this module
wont compile.
From microsofts help files:
"You can combine declaring an object variable with assigning an object to it
by using the New keyword with the Set statement. For example:Set MyObject =
New Object ' Create and Assign"
'-------------------------------------------------------------------------
Type myData
age As Integer
wageEarner As Boolean
End Type
Sub testReference()
Dim person As myData
' here I believe I created the pointer to my object person
Set personPtr = New person
' here I am giving my object some data
person.age = 10
person.wageEarner = True
'here I pass my reference to my object person in the following
subroutine
examineData (personPtr)
End Sub
Sub examineData(aPerson As myData)
If (aPerson.wageEarner = True) Then
MsgBox "The age is " + Trim(Str(aPerson.age)) + Chr(13) + _
"They are wage earner"
Else
MsgBox "The age is " + Trim(Str(aPerson.age)) + Chr(13) + _
"They are wage earner"
End If
End Sub
that objects address in a subroutine called examineData, which should
produce a msgbox detailing the information placed in the object "person".
I believe I am passing a reference address to my object I created in
subroutine testReference, to the subroutine examineData. But this module
wont compile.
From microsofts help files:
"You can combine declaring an object variable with assigning an object to it
by using the New keyword with the Set statement. For example:Set MyObject =
New Object ' Create and Assign"
'-------------------------------------------------------------------------
Type myData
age As Integer
wageEarner As Boolean
End Type
Sub testReference()
Dim person As myData
' here I believe I created the pointer to my object person
Set personPtr = New person
' here I am giving my object some data
person.age = 10
person.wageEarner = True
'here I pass my reference to my object person in the following
subroutine
examineData (personPtr)
End Sub
Sub examineData(aPerson As myData)
If (aPerson.wageEarner = True) Then
MsgBox "The age is " + Trim(Str(aPerson.age)) + Chr(13) + _
"They are wage earner"
Else
MsgBox "The age is " + Trim(Str(aPerson.age)) + Chr(13) + _
"They are wage earner"
End If
End Sub