Results 1 to 4 of 4

Thread: defining properties

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2005
    Posts
    30

    Unhappy defining properties

    sup
    i have a register application with many different products that i'd like to assign different properties to. i already have things like
    VB Code:
    1. 'Product stuff
    2.     Public Const pro As String = "PRODUCT"
    3.     Public Const pro_sm As Integer = 3.79
    4.     Public Const pro_lg As Integer = 5.99

    but i would like to have them contain properties like
    VB Code:
    1. Dim pro As Combo
    and define exactly what Combo means, in the same way the application knows what Integer or String means.
    in other words, i want to create my own object (i think)

    as you can see, i'm very confused as to what i need to do, but any help, or link to other thread/help is greatly appreciated.

    thanks
    stephen

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: defining properties

    If you create something like this:

    VB Code:
    1. public class SomeClass
    2.  'Stuff in here
    3. end class

    Then you can use it just like the other items:

    VB Code:
    1. dim sc as New SomeClass

    However, you have to have that New in there somewhere.

    Thus, what you are looking for are classes (or structures, which are similar). However, there are many steps along that path, and this is the smallest of them. Classes are easy to use, and they are easy to use poorly, but that's where learning comes from. Object oriented design is a large and difficult subject, but you don't need to know it all to use a part of it.
    My usual boring signature: Nothing

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: defining properties

    Create a class called Combo, define a few Public Properties in it. Then, in the 'parent' (current) class, declare a Public Property of type Combo.

    Quick example, without syntax checking.

    VB Code:
    1. Public Class MainClass
    2.  
    3. Public Property XYZ() As String
    4. 'Get
    5. 'Set
    6. End Property
    7.  
    8. Public Property MyCombo() As Combo
    9. 'GEt
    10. 'Set
    11. End Property
    12.  
    13. End Class
    14.  
    15. Public Class Combo
    16.  
    17. Public Property Name() As String
    18. 'Get
    19. 'Set
    20. ENd Property
    21.  
    22. Public Property Value() As String
    23. 'Get
    24. 'Set
    25. End Property
    26.  
    27. End Class

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: defining properties

    There's the next step.

    By the way, have you been working with classes at all before? I guessed that you had not, but if I was wrong, my post was pretty elementary. If I guessed right....well, it is the way to start out. Everything else is easier.
    My usual boring signature: Nothing

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