|
-
Jun 26th, 2002, 09:14 AM
#1
Property Set *RESOLVED*
If, say for example, I am passing an imagelist to a property would I use:
VB Code:
Public Property Set ImageList(ByVal Value As Object)
Set milsImageList = Value
End Property
Public Property Get ImageList() As Object
Set ImageList = milsImageList
End Property
or
VB Code:
Public Property Set ImageList(ByVal Value As Variant)
Set milsImageList = Value
End Property
Public Property Get ImageList() As Variant
Set ImageList = milsImageList
End Property
Basically, Variant or Object as the passed parameter...?
Woka
Last edited by Wokawidget; Jul 1st, 2002 at 10:35 AM.
-
Jun 26th, 2002, 09:04 PM
#2
PowerPoster
If you know what you are setting/getting then you should declare it as what it is:
VB Code:
' Class declarations
Private m_TextBox As TextBox
Public Property Get NotePad As TextBox
' I can't ever remember if you need to use Set here or not
Set NotePad = m_TextBox
End Property
Public Property Set NotePad(TextBox As TextBox)
' ditto about using Set
Set m_TextBox = TextBox
End Property
-
Jun 27th, 2002, 03:33 AM
#3
Arrrrr....USA Pledge...BANNED! Hahaha
Can't do...Can't decalare an imagelist as a varible in a public property in a DLL, VB won't allow it
-
Jun 27th, 2002, 04:40 AM
#4
New Member
Is ImageList just a property name? Aren't there any controls or class that has that name? Anyway, I only want to say that i was a bit confused with your sample code. You used Byval keyword for an Object type variable. To what I understand, Object type variables, even for some Variant subtypes, can only be passed ByRef-erence.
-
Jun 27th, 2002, 05:10 AM
#5
The CEO is involved...
Dunno about that, but ByVal works fine...
-
Jun 29th, 2002, 01:43 AM
#6
New Member
Gush. I'm talking in a Marsian language!
Sorry bout that! Kinda tensed being a newbie.
-
Jun 29th, 2002, 02:14 AM
#7
I think you would use Set, but for no other reason then it seems to be the industry standard when working with Objects and it more clearly defines that in fact you are working with Object(s) since they are the only thing that gets set. Although functionaly they are the same.
-
Jul 1st, 2002, 03:09 AM
#8
Oooo...vbForums...New color...
I always do use SET...
Do I pass the object in as a Variant, or as an Object varible???
Woka
-
Jul 1st, 2002, 03:51 AM
#9
New Member
Well
Variants are universal. They can hold almost any var types.
Should I use variant param for objects, i always check if passed value is an object, eg
VB Code:
Public Property Set PropName(YourParam as Variant)
If Not IsObject(YourParam) Then
'Raise an error
End If
Set mPropName = YourParam
End Property
Unlike declaring [YourParam] as Object, VB will do the validating,eg
VB Code:
Public Property Set PropName(YourParam as Object)
Set mPropName = YourParam
End Property
Either way, ok.
Something like that.
Hope I'm in the right lang now.
-
Jul 1st, 2002, 10:32 AM
#10
Well since a variant can hold an object or other types of data and we know that the control is an object then object seems the lesser evil. Although I'm not sure it matters much. Also declaring it as an Object will force you to use set and follow the rules for an object more than a variant.
-
Jul 1st, 2002, 10:34 AM
#11
It's a great morning, now don't feed me cereal!
That's what I thought 
Cheers for your replies...
Woka
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
|