Avatar of altariamx2003
altariamx2003Flag for Mexico

asked on 

how to use a structure as property of a vb class??

Hi

I have this class
Public Class data
    Public Structure ParamCar
        Public Alfa As Double
        Public Eta As Double
        Public Mw7P As Double
        Public Z7P As Double
        Public Sg7P As Double
        Public Cf As Double
        Public Kw As Double
        Public Ja As Double
        Public Ya As Double
        Public Nscn As Integer
        Public Banderascn As Integer
        Public Metdesdob As Integer
        Public n As Integer
        Public metSg As Integer
        Public metTb As Integer
        Public metCriticas As Integer
        Public metTc As Integer
        Public metPc As Integer
        Public metomega As Integer
        Public ieq As Integer
    End Structure

    Private _mystructure As data.ParamCar
    Public Property mystructure() As data.ParamCar
        Get
            Return _mystructure
        End Get
        Set(ByVal value As data.ParamCar)
            _mystructure = value
        End Set
    End Property

    Private _name As String
    Public Property name() As String
        Get
            Return name
        End Get
        Set(ByVal value As String)
            dmyarray1 = value
        End Set
    End Property
End Class

Open in new window


-------------------------------------------------------------------------------------------------------------------------------
and when I tried to use it
        
     Dim example As New data()
        example.mystructure.Alfa = 34

Open in new window


vb show me the following error: "Expression is a value and therefore cannot be the target of an assignment"
 User generated image-----------------------------------------------------------------------------------------------------------------
What Im doing wrong?

It is ok how I declare and use the structure as a property???

why vb show that error???
Visual Basic.NET

Avatar of undefined
Last Comment
altariamx2003
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of altariamx2003
altariamx2003
Flag of Mexico image

ASKER

mmm

something like this??
Public Class data
    Public class ParamCar
        Public Alfa As Double
        Public Eta As Double
        Public Mw7P As Double
        Public Z7P As Double
        Public Sg7P As Double
        Public Cf As Double
        Public Kw As Double
        Public Ja As Double
        Public Ya As Double
        Public Nscn As Integer
        Public Banderascn As Integer
        Public Metdesdob As Integer
        Public n As Integer
        Public metSg As Integer
        Public metTb As Integer
        Public metCriticas As Integer
        Public metTc As Integer
        Public metPc As Integer
        Public metomega As Integer
        Public ieq As Integer
    End class

    Private _mystructure As new data.ParamCar
    Public Property mystructure() As data.ParamCar
        Get
            Return _mystructure
        End Get
        Set(ByVal value As data.ParamCar)
            _mystructure = value
        End Set
    End Property

    Private _name As String
    Public Property name() As String
        Get
            Return name
        End Get
        Set(ByVal value As String)
            dmyarray1 = value
        End Set
    End Property
End Class

Open in new window

That's right.  Does it work now?
Avatar of altariamx2003
altariamx2003
Flag of Mexico image

ASKER

yes its works

may I ask you another question???

another of the properties of my class are arrays, for example

    Private _myArray(,) As Double
    Public Property myArray() As Double(,)
        Get
            Return _myArray
        End Get
        Set(ByVal value As Double(,))
            _myArray = value
        End Set
    End Property

Open in new window


is there a way to change this property from two-dimentional array to a two-dimentional list?
Hmm...you can try using a List(Of List(Of Double)).
Avatar of altariamx2003
altariamx2003
Flag of Mexico image

ASKER

hheee sorry bro could you help me with some example about how to use a two-dimensional list as a property in a class??

this is the first time that I tried to use list
Avatar of altariamx2003
altariamx2003
Flag of Mexico image

ASKER

nevermind I gonna keep with the property as array, the issue about how to change it to list it is just to know and be a better programmer
Avatar of altariamx2003
altariamx2003
Flag of Mexico image

ASKER

Thanks for your time Idle
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo