Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

Trouble exporting a Table when using my own methods.

If I was able to do
Dim dt As New MyTable
    dt.Export.ToCSV()
Or even simpler
Dim dt As New MyTable
    dt.ExportToCSV()
When ever ExportToCSV is called, how does it know what table to export without me passing that table in?
0
rgn2121
Asked:
rgn2121
  • 5
  • 2
1 Solution
 
rgn2121Author Commented:
TechTiger007:
ExportToCSV will be called on an object of MyTable which itself is a datatable.
Inside your Export method get the base class of the object which is a datatable and perform the operation on this object
0
 
rgn2121Author Commented:
That is what I am not sure about...Normally I pass in a destination file path of where it is to be exported and the table to export.

Sub ExportToCSV()

...Some Code

End Sub
0
 
rgn2121Author Commented:
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
Wayne Taylor (webtubbs)Commented:
Hi rgn2121,

When calling a method of an object (in this case, a MyTable object, which inherits from DataTable), you can access the underlying DataTable using the "Me" keyword.

Regards,

Wayne
0
 
rgn2121Author Commented:
What if I use your nested class example?  Me would then refer to the ExportClass correct?
0
 
Wayne Taylor (webtubbs)Commented:
>>Me would then refer to the ExportClass correct?

Yes, if used in the ExportClass class. To "attach" a table to the ExportClass, pass it with the New procedure, as below.

The question I have though, is do you really need the ExportClass? Probably not. I'd simply have an ExportToCSV() routine in the MyTable class.

Wayne
Public Class MyTable
    Inherits System.Data.DataTable 
    Sub New()
        MyBase.New()
    End Sub 
    Public Property Export() As ExportClass
        Get 
        End Get
        Set(ByVal value As ExportClass)
            value.Table = Me
        End Set
    End Property 
    Public Class ExportClass
        Public Table As MyTable
        Public Sub New(ByVal mt As MyTable)
            Me.Table = mt
        End Sub
        Public Function ToCSV() As Boolean
            'export the table "Table"
        End Function
    End Class 
End Class

Open in new window

0
 
rgn2121Author Commented:
>>The question I have though, is do you really need the ExportClass? Probably not. I'd simply have an >>ExportToCSV() routine in the MyTable class.

No...I was just curious...I really do appreciate all the help...Thanks.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now