Avatar of altariamx2003
altariamx2003
Flag 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"
 example-----------------------------------------------------------------------------------------------------------------
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

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mike Tomlinson

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
altariamx2003

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

Mike Tomlinson

That's right.  Does it work now?
altariamx2003

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?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Mike Tomlinson

Hmm...you can try using a List(Of List(Of Double)).
altariamx2003

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
altariamx2003

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
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
altariamx2003

ASKER
Thanks for your time Idle