|
-
Jul 6th, 2000, 06:14 AM
#1
Thread Starter
Lively Member
How do I use the Property Get/Set/Let directly on the class?
You'll understand what I mean by the example.
Code:
Dim A As New MyClass
A=5
MsgBox A
As far as I have seen, I can do the Property on the members of the class. Ie. A.Member1 = 5, MsgBox A.Member1
-
Jul 6th, 2000, 06:39 AM
#2
Member
I don't see what you want ?
If you want to access a member of your class, then your last sentence answer your question
If you want an explanation about properties so try to check out one of my thread called Something interresting. There's an example of property Let, Get use.
-
Jul 6th, 2000, 07:03 AM
#3
Thread Starter
Lively Member
No. I want to use Property Let/Get/Set on the Instance of the class. Not one of its properties.
Ie.
MsgBox Textbox1.Text
outputs the same as
MsgBox Textbox1
Code:
Dim A as new MyClass
A.Text="Test" 'This is easy
'But how do I do:
A="Test" '?
How do i set the property of A?
-
Jul 6th, 2000, 07:16 AM
#4
New Member
Variable In The Class
The default property for a class is the not the text property like it is for a text box. Or at least I don't think so. I don't know what the default is, but I don't think you can just set the text of the class without specifying .text. Isn't a class just an encompassing variable to hold other varibles in it?? Maybe I'm totally in left field... just trying to help...
Jonathan (Co President - Big Berdie International)
Karl Moore RULEZ!
"Pipers Do It With Amazing Grace!"
-
Jul 6th, 2000, 07:24 AM
#5
Member
If I understand, ...
For example, if you want to affect a string to your class, define this:
Code:
'In your Module Class
Public Property Let Name (S as string)
X = S ' Where X is used in your class
End property
Public Property Get Name () as String
Name = X
End Property
If you want to affect a value to your class use this:
YourClass.Name = "What you want"
If you want to get the value of something in your class, use this:
Code:
Dim YourString as String
YourString = YourClass.Name
I hope this will answer your question.
Now, if you want to set a property as default of a class, let me a little moment to find how to do this, is it possible but I don't remember how.
-
Jul 6th, 2000, 07:33 AM
#6
Member
Here,
In the Tools Menu, select the second item (sub attributes or something like that! My software is in French)
Select the property you want to set by default. Click on the Advanced>> button and in the Sub Id field, select "default". Validate and there we are.
-
Jul 6th, 2000, 12:46 PM
#7
Thread Starter
Lively Member
Yup. It was the default i was after. Only hoped it could be declared something like this
"property let ~(X as string)"
or something where '~' is a symbol representing the class.
Then I can have a class with only one property. Itself. Not a MyClass.PropertyName property.
I want:
MyClass = ...
not
MyClass.PropertyName = ...
Think I finally made myself clear.
Thanks for the help. If you got something more on this subject, please reply.
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
|