Solved

Trouble exporting a Table when using my own methods.

Posted on 2008-11-01
7
208 Views
Last Modified: 2013-11-26
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
Comment
Question by:rgn2121
  • 5
  • 2
7 Comments
 
LVL 12

Author Comment

by:rgn2121
ID: 22856097
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
 
LVL 12

Author Comment

by:rgn2121
ID: 22856098
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
 
LVL 12

Author Comment

by:rgn2121
ID: 22856108
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 22856129
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
 
LVL 12

Author Comment

by:rgn2121
ID: 22856137
What if I use your nested class example?  Me would then refer to the ExportClass correct?
0
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 22856151
>>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
 
LVL 12

Author Comment

by:rgn2121
ID: 22856160
>>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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
DataGridView Events ? 3 37
Problem to error 4 45
SQL Exceptions 3 38
Point to Current Row Ater Refresh Datagridview 3 20
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now