LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Creating Object Variables - and passing them as arguements

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



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA - passing Variables to subroutines Madduck Excel Discussion (Misc queries) 12 September 19th 08 03:20 AM
Passing Variables Jeff Excel Discussion (Misc queries) 1 November 4th 05 06:46 PM
VBA passing variables through a function Jeff Excel Discussion (Misc queries) 2 November 3rd 05 11:23 PM
Passing variables between a form and macro David New Users to Excel 1 October 5th 05 04:42 AM
passing variables from excel to word Mike NG Excel Programming 8 July 22nd 03 12:08 PM


All times are GMT +1. The time now is 02:47 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"