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

  • Home
  • SEARCH
  • 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 565161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:50:35+00:00 2026-05-13T12:50:35+00:00

I am trying to design a table type structure that contains rows and cells.

  • 0

I am trying to design a table type structure that contains rows and cells. I intend the cell class to have a value property. I’m trying to work out how I can create a value that can return some defined different types e.g integer, single, date, string. I’d like the cell value to be strongly typed, but I am unsure how best to get this working.

My thinking in code so far:

Public Class Cell
  Private _value as object
  Public Property Value as Object    // How can I define this so that it return a Type 
    Get                              // e.g. integer, string, etc
      Return _value 
    End Get
    Set(ByVal value as object)
      _value = value
    End Set
End Class

Public Class Row
  Dim _Cells as New List(Of Cell)
  Public Function AddCell(ByVal c as Cell) as Cell
     _Cells.Add(c)
     Return _Cells(_Cells.count - 1)
  End Function
  • 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-13T12:50:35+00:00Added an answer on May 13, 2026 at 12:50 pm

    Here a simple solution using basic inheritance and even without generics. The idea is that you have a single parent class for all cells. And a different cell class per column type. This make possible to declare list of cells in a Row object. Because of there may be different cell types within a single row, you can’t declare it (list of cells) as a list of some specific cell type. But you can use cell’s parent class in this case. In short here is example:

    Public Class Cell
    End Class
    
    Public Class Cell_Id
        Inherits Cell
        Public Value As Integer
    End Class
    
    Public Class Cell_Name
        Inherits Cell
        Public Value As String
    End Class
    
    Public Class Cell_MonthlyTax
        Inherits Cell
        Public Value As Double
    End Class
    
    
    Public Class Row
        Public Cells As New List(Of Cell)
    
        Public Sub AddCell(ByVal cell As Cell)
            Cells.Add(cell)
        End Sub
    End Class
    
    
    Module Module1
    
        Sub Main()
            Dim row1 As New Row()
            row1.AddCell(New Cell_Id() With {.Value = 1})
            row1.AddCell(New Cell_Name() With {.Value = "Name1"})
            row1.AddCell(New Cell_MonthlyTax() With {.Value = 12.2})
            Dim row2 As New Row()
            row2.AddCell(New Cell_Id() With {.Value = 2})
            row2.AddCell(New Cell_Name() With {.Value = "Name2"})
            row2.AddCell(New Cell_MonthlyTax() With {.Value = 47.9})
            Dim row3 As New Row()
            row3.AddCell(New Cell_Id() With {.Value = 3})
            row3.AddCell(New Cell_Name() With {.Value = "Name3"})
            row3.AddCell(New Cell_MonthlyTax() With {.Value = 73.3})
    
            Dim rows As New List(Of Row)(New Row() {row1, row2, row3})
    
            ' here you loop through rows, in each row select Cell at index 2, cast it down to a specific
            ' type (yes, you should tell to a compiler that you sure that Cell at index 2 is of Cell_MonthlyTax type)
            ' After casting you will get intellisence and see that Value is of Double type.
            ' In cellsOfColumn2 you will get an array of Double (this is not exactly array, but it doesn't matter in our case)
            Dim cellsOfColumn2 = From row In rows Select DirectCast(row.Cells(2), Cell_MonthlyTax).Value
    
            ' here you may work with array of values as you want, say calculate avarange value
            Dim result = cellsOfColumn2.Average()
        End Sub
    
    End Module
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 322k
  • Answers 322k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use WindowManager.getDefault().getMainWindow() as parent for JFileChooser dialog. May 14, 2026 at 12:51 am
  • Editorial Team
    Editorial Team added an answer I would go with using JSON for this example, your… May 14, 2026 at 12:51 am
  • Editorial Team
    Editorial Team added an answer Better idea, solved: function myClass_IE() { this.myName = function ()… May 14, 2026 at 12:51 am

Related Questions

I'm a novice to SQL scripting. I am trying to figure out a design
Im currently working on a site which will contain a products catalog. I am
I am trying to create a check constraint on an access (jet?) table. So,
I want to create a table in MS SQL Server 2005 to record details
Is there any way to access a dynamically accessing member of a User- defined

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.