Passing an Object as a parameter for sub-routine

my_lou

Well-known member
Joined
Nov 10, 2003
Messages
45
hi folks,

i have this sub-routine that needs to be able to take an Object as a parameter. so the routine looks something like this:

Sub AlignAlpha(ByRef FormToInitialize As System.Windows.Forms.Form)
.....
End Sub

and then i have this form called CourseSelPanel.vb and within it, i need to be able to call the sub-routine AlignAlpha and pass the object CourseSelPanel itself as a parameter.

so i guess something like this:

Friend Class CourseSelPanel
Inherits System.Windows.Forms.Form
...............
AlignAlpha(pass CourseSelPanel as a parameter???????)
...............
End Class

How do i do that?

Thanks all.
 
oh ok, that makes sense. there is another problem though, the function AlignAlpha will be called from several different forms and it needs to be flexible enough to where it would be able to receive a parameter Object reference to any of those different froms. For example, if i am calling AlignAlpha from the form CourseSelPanel.vb then it should be able to take an Object of type CourseSelPanel as input, if i am calling from another object called ShippingPanel.vb then it should be able to take ShippingPanel Object as an input and so on.

i tried declaring the input parameter as a Form, i.e. something like this:
Sub AlignAlpha(ByRef FormToInitialize As System.Windows.Forms.Form),

but that didnt give me access to the specific methods for the different forms calling the function. Then i tried declaring is as an Object, i.e.:

Sub AlignAlpha(ByRef FormToInitialize As Object),

but that only gives me access to one method, GetType.

what can i do?
thanks.
 
Back
Top