Home All Groups Group Topic Archive Search About

Class with properties

Author
3 Mar 2006 8:52 PM
Carlos Albert
Hello world,

I'm trying to do a class "Product" with properties, so you should be able to
access:
  Product_Class(Product_Code).Product_Name
  Product_Class(Product_Code).Product_Price
  Product_Class(Product_Code).Product_Description

Etc.

I tried many things but obviously I'm doing something wrong because doesnt
work at all. This is the code I end up with, if somebody wants to give me a
hint will gonna be very much welcome. Tnx.

Class Prueba

     Sub Test()
  Dim ProductName As String = Products.Product(1).Name
  Dim ProductPrice As String = Products.Product(1).Price
  Dim ds as new DataSet
  ds = Products.Listado
     End Sub

     Class ProductProperty

  Public ReadOnly Property Name() As String
      Get
   Return "Name of " & Code  '  How can I get the code here?
      End Get
  End Property

  Public ReadOnly Property Price(ByVal Code As String) As Decimal
      Get
   Return "Price of " & Code  '  How can I get the code here?
      End Get
  End Property

     End Class

     Public Class Products

  Default Public ReadOnly Property Product(ByVal Code As String) As
ProductProperty
      Get
   '  What do I do here?
      End Get
  End Property

  Public Function Listado() as DataSet
      '  Blah, blah
      Dim ds as New DataSet
      Return ds
  End Function

     End Class

End Class

AddThis Social Bookmark Button