Salem Ahmed Salem Ahmed - 6 months ago 38
Vb.net Question

How can I find the form that called the current method?

When logging in vb.net, how can I learn the name of the form that called the current method?
I know all about


System.Reflection.MethodBase.GetCurrentMethod().


so I used this

vb.net

Dim form_Name as String=(New System.Diagnostics.StackTrace).GetFrame(1).GetMethod.GetParameters(1).Member.DeclaringType.FullName


c#

string form_Name = (new System.Diagnostics.StackTrace()).GetFrame(1).GetMethod.GetParameters(1).Member.DeclaringType.FullName;


But I faced a problem using
Form_Name
as
Form


I am hoping to find a way, I want to get the Form object name to use it as Form not string

Answer

VB: Dim callingForm = Application.OpenForms.Item(form_Name)

Comments