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 7022395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:34:36+00:00 2026-05-27T23:34:36+00:00

I have a question related with VB.Net Code. I see that the DataTable we

  • 0

I have a question related with VB.Net Code.

I see that the DataTable we can use:

DataTable(0) ' This return a DataRow with the selected index

In the intellisense I see that this functionality can achieve with a extension… but, If I create a extension, always I need refer the Extension before to use it

Public Module asdadsdas
    <System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)>
    <System.Runtime.CompilerServices.ExtensionAttribute()>
    Friend Function MyExt(ByVal pMyObject As MyObject, ByVal ColumnName As String) As MyObject.ColumnData

        Return pMyObject.Columns(0)

    End Function
End Module

Public Class MyObject
    Friend Structure ColumnData
        Friend vNombre As String
        Friend vApellido As String
        Friend vTelefono As String

        Public Property Nombre As String
            Get
                Return Me.vNombre
            End Get
            Set(ByVal value As String)
                Me.vNombre = value
            End Set
        End Property

    End Structure

    Friend Columns() As ColumnData

    Public Sub add(ByVal MyColumn As String)
        ReDim Columns(0)
        Columns(0).vNombre = MyColumn
    End Sub

End Class

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Test As New MyObject
        Test.add("TEST 001")
        ' HERE IS THE PROBLEM
        Test("TEST 001")
        ' CORRECT USE
        Test.MyExt("TEST 001")
    End Sub
End Class

Now, my concrete question: How I can make a default extension in a specific Object?


@competent_tech: man you are a genius… thanks by your comment!

This is the solution of my problem:

Public Class ColumnData
Friend Name As String
Friend LastName As String
Friend Phone As String

End Class

Public Class MyColumns
Friend Data() As ColumnData

Default Property Item(ByVal ColumnName As String) As ColumnData
    Get
        Return Data(0)
    End Get
    Set(ByVal value As ColumnData)

    End Set
End Property

Public Sub add(ByVal Name As String, ByVal LastName As String, ByVal Phone As String)
    If Data Is Nothing Then
        ReDim Data(0)
        Data(0) = New ColumnData
    End If

    With Data(0)
        .Name = Name
        .LastName = LastName
        .Phone = Phone
    End With


End Sub

End Class

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim Test As New MyColumns

    Test.add("Name 001", "bolanos.m", "500-2004-1000")

    Debug.Print(Test("Name 001").LastName & " - " & Test("Name 001").Phone)
    ' bolanos.m - 500-2004-1000

    Test("Name").LastName = "BOLANOS.M MODIFY"

    Debug.Print(Test("Name 001").LastName & " - " & Test("Name 001").Phone)
    ' BOLANOS.M(MODIFY - 500 - 2004 - 1000)
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-27T23:34:36+00:00Added an answer on May 27, 2026 at 11:34 pm

    Why not just add default properties to the MyObject class?

    Default Public Property IndexedColumn(index As String) As ColumnData
        Get
            Return Columns(index)
        End Get
        Set(value As ColumnData)
            Columns(index) = value
        End Set
    End Property
    Default Public Property IndexedColumn(index As Integer) As ColumnData
        Get
            Return Columns(index)
        End Get
        Set(value As ColumnData)
            Columns(index) = value
        End Set
    End Property
    

    You will need to change the exposure level of the structure and the access will be:

        Dim oColumnData = Test("TEST 001")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Another question related to this one . I have a List<SortableObjects> that is the
I have a question related to this one . I don't want to do
I have a question related to this one : I'm trying to attach an
I have this source code where I got it from net tutsplus. I have
I have already asked this question on SuperUser but it was suggested there that
I have seen this question and a number of blog posts related to using
I'll preface this by saying that I usually work in C#/.Net. Normally, I use
This question is related to this other question I recently asked... cf.net exception and
Sorry if this is generic in nature, but I have a question that maybe
I posed a question that related where I could display Page loading in asp.net

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.