Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27201

VS 2008 Pointers* to objects (*Not supported but you know what I mean)

$
0
0
Hi,

I have a form with a button that calls a public sub
Code:

(Public Sub btnImport_Experiment_Data_Files_OLS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImport_Experiment_Data_Files_OLS.Click)
which all works fine.

I now have another form which also needs to call this same code.
I've worked out how to identify which form called the sub using
Code:

CType(sender, Button).Name
, but what I'm really looking for is a way to setup the equivalent of pointers to the 4 controls that exist on both forms, so at the beginning of the sub, I'll setup these pointers to either the 4 controls on 1 form or the 4 controls on the other form, depending on which form called the sub.

Now this next line
Code:

Dim textbox As Object = Me.txtNumber_of_Data_Files_Imported
works fine, but this one doesn't:
Code:

Dim textbox As Object = frmNon_Titration.txtNumber_of_Data_Files_Imported
So it seems I can reference (or point) to an object if it is on the same form as the code, but not if it is on another form..
My only other thought was move all the code into a public function and pass the names of all the controls to it


So, Any thoughts on how to create a reference to an object (textbox or listbox etc) on another form?

Thanks

Kristian

Viewing all articles
Browse latest Browse all 27201

Trending Articles



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