Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Storing Objects ByRef

$
0
0
So this is going back to the concept of Pointers in C++.

Basically, what I want to do is instantiate an Object in one class, pass it to another ByRef (which should work like a pointer, right?) and then store the reference in a local variable so I can use it in the class.

i.e.

Public Class Process
    Private _db As AccessFacade

    Public Sub SetDB(ByRef db As AccessFacade)
        _db = db
    End Sub
End Class

Public Class Main
    Private Sub OpenProcess()
        Dim process As New Process
        process.SetDB(_db)
    End Sub
End Class
I mean, assuming that Class Main has a private _db that is an AccessFacade, etc.

Basically I have a class that's going to act as a gateway between the application and the database. Since it's a DB driven application, it will see lots of use. Rather than instantiating it every time I want to run a query, or on every form, I'd like to just start it when the application starts and keep it alive.

Is there a more appropriate way to do this that I might be missing?

Thanks!

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>