Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3785526
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:32:31+00:00 2026-05-19T11:32:31+00:00

I am trying to figure out the best approach for setting and getting properties

  • 0

I am trying to figure out the best approach for setting and getting properties in a nested class I am creating.

I have a class, Car which has a nested class ControlPanel and want to make the properties of the Control Panel only accessible to the Car and Control Panel class.

(ie: not within the assembly or namespace and not within the application the class library will be going to be used)… I have changed the class access properties to friend, protected friend, private, public, but any combination is not matching my expected results.

I want to change the properties in the Drive() Sub of a class as shown below.

Any thoughts?

 Public Class Car

    Dim cp As New ControlPanel

    Public Class ControlPanel
      Private _Speedometer As Integer = 0
      Private _Odometer As Integer = 0

      Public Property Speedometer() As Integer
        Get
            Return _Speedometer
        End Get
        Protected Set(ByVal value As Integer)
            _Speedometer = value
        End Set
      End Property

      Public Property Odometer() As Integer
        Get
            Return _Odometer
        End Get
        Protected Set(ByVal value As Integer)
            _Odometer = value
        End Set
     End Property

    End Class

   Public Sub Drive()

        cp.Odometer = 76323
        co.Speedometer = 86

   End Sub

End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T11:32:32+00:00Added an answer on May 19, 2026 at 11:32 am

    You can do it like this:

    Public Class Car
    
      Private Interface IControlPanel
        Property Odometer As Integer
        Property Speedometer As Integer
      End Interface
    
      Public Class ControlPanel
        Implements IControlPanel
        Public ReadOnly Property Odometer As Integer
          Get
            Return CType(Me, IControlPanel).Odometer
          End Get
        End Property
        Public ReadOnly Property Speedometer As Integer
          Get
            Return CType(Me, IControlPanel).Speedometer
          End Get
        End Property
        Private Property IControlPanel_Odometer As Integer Implements IControlPanel.Odometer
        Private Property IControlPanel_Speedometer As Integer Implements IControlPanel.Speedometer
      End Class
    
      Dim cp As IControlPanel = New ControlPanel()
    
      Public Sub Drive()
        cp.Odometer = 76323
        cp.Speedometer = 86 
      End Sub
    
    End Class
    

    It uses a private interface nested in the Car class with privately implemented and aliased members in ControlPanel. This way, only Car can access the interface members.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out the best way to approach this. I have a
I'm trying to figure out the best approach, more specifically which JOIN to use,
I am trying to figure out the best approach to have a link with
I'm trying to figure out the best approach to display combined tables based on
I'm trying to figure out the best way to do this, but I'm getting
I'm trying to figure out the best way to approach the following: Say I
I'm trying to figure out the best approach to take in my current situation.
I'm just trying to figure out the best approach for running a scolling background
I'm trying to figure out the best way to approach writing a universal app
I am trying to figure out if my approach is proper. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.