|
-
Apr 24th, 2002, 06:01 PM
#1
Thread Starter
Lively Member
Passing classes into a function
Lets say I've got a function, and i need it to do somthing to an instance of my class, and that is the parameter of the function. I'm trying to do somthing like this:
The function gets the .name property from the instance of the class and shows it in a msgbox (not what my function really does, but this makes it a bit more simple)
Function GetName (ClassInstance as string)
msgbox ClassInstance.Name
End Function
So when I call it like this supposing that Player1 is an instance of my class, it doesnt work.
Getname (Player1)
How can i get around this?
-
Apr 24th, 2002, 06:14 PM
#2
Instead of decalring the parameter as a string yo uneed to declare as the class. For instance if the class is called cPlayerInfo then the declare the function like this:
VB Code:
Function GetName (ClassInstance as cPlayerInfo) as string
GetName =ClassInstance.Name
End Function
-
Apr 24th, 2002, 07:05 PM
#3
Thread Starter
Lively Member
Thanks, I figured it out just before I read this... heheh, dont know what i was thinking. Thanks anyways though.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|