Results 1 to 7 of 7

Thread: Property and Classes?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Norway
    Posts
    112
    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

  2. #2
    Member
    Join Date
    Jun 2000
    Location
    North of France
    Posts
    49

    Question

    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.
    Hi-Tech Engineer

  3. #3

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Norway
    Posts
    112
    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?

  4. #4
    New Member
    Join Date
    Jun 2000
    Location
    Canada
    Posts
    8

    Arrow 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!"

  5. #5
    Member
    Join Date
    Jun 2000
    Location
    North of France
    Posts
    49

    Exclamation 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.
    Hi-Tech Engineer

  6. #6
    Member
    Join Date
    Jun 2000
    Location
    North of France
    Posts
    49

    Lightbulb

    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.
    Hi-Tech Engineer

  7. #7

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Location
    Norway
    Posts
    112

    Smile

    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
  •  



Click Here to Expand Forum to Full Width