B
Bugs
Hi,
I wonder if anyone can help me out.
I'm building a vb.net application that has a form with a panel that
contains several other sub forms (as a collection of controls). What
I'm wanting to do is call a generically named public sub in the
top-most sub form in the panel.
I have the name of the top-most form as a string (eg. g_TopForm =
"frmCustomers") and I can reference the form with:
Me.pnlMainWindow.Controls.Item(FormRef)
where the FormRef integer is derived from the function call:
FormRef = FormItemNo(g_TopForm)
and the FormItemNo function is defined as:
Private Function FormItemNo(ByVal formname As String) As Integer
Dim itemref As Integer
Try
'Return impossible number if the form hasn't already been
opened
FormItemNo = 99
For itemref = 0 To Me.pnlMainWindow.Controls.Count - 1
If Me.pnlMainWindow.Controls.Item(itemref).Name =
formname Then FormItemNo = itemref
Next
Catch exp As Exception
MsgBox(exp.Message, MsgBoxStyle.Critical, Me.Text)
End Try
End Function
So, what I'd like to be able to do now is somehow derive a variable
(say subfrm) of type 'frmCustomers' and call:
subfrm.NewRec()
where NewRec() is a public sub in the frmCustomers form class.
Am I barking up completely the wrong tree with this approach or does
anyone have a simple solution to this? I'm not very adept in .net
programming yet (as you may have gathered?!)
Any help is very much appreciated.
Paul
I wonder if anyone can help me out.
I'm building a vb.net application that has a form with a panel that
contains several other sub forms (as a collection of controls). What
I'm wanting to do is call a generically named public sub in the
top-most sub form in the panel.
I have the name of the top-most form as a string (eg. g_TopForm =
"frmCustomers") and I can reference the form with:
Me.pnlMainWindow.Controls.Item(FormRef)
where the FormRef integer is derived from the function call:
FormRef = FormItemNo(g_TopForm)
and the FormItemNo function is defined as:
Private Function FormItemNo(ByVal formname As String) As Integer
Dim itemref As Integer
Try
'Return impossible number if the form hasn't already been
opened
FormItemNo = 99
For itemref = 0 To Me.pnlMainWindow.Controls.Count - 1
If Me.pnlMainWindow.Controls.Item(itemref).Name =
formname Then FormItemNo = itemref
Next
Catch exp As Exception
MsgBox(exp.Message, MsgBoxStyle.Critical, Me.Text)
End Try
End Function
So, what I'd like to be able to do now is somehow derive a variable
(say subfrm) of type 'frmCustomers' and call:
subfrm.NewRec()
where NewRec() is a public sub in the frmCustomers form class.
Am I barking up completely the wrong tree with this approach or does
anyone have a simple solution to this? I'm not very adept in .net
programming yet (as you may have gathered?!)
Any help is very much appreciated.
Paul