|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Getting the current procedure name?is there any way to get the name of the current running procedure? For example: Public Sub Test( ) 'do something '... 'log activity (for example) objLog.Write(Text := "bla bla bla", _ ProcName := dontKnowWhatIsThis.GetProcName() ) End Sub Any possibility? Cesar I don't think it anything will return "Public Sub Test" in your
example, but here's a thread that discusses a few methods: http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_thread/thread/8d8ec2d0f77e7f88/c23a0015ecf89e47?lnk=gst&q=current+method+name&rnum=2#c23a0015ecf89e47 Thanks, Seth Rowe Ronchese wrote: Show quoteHide quote > Hello, > > is there any way to get the name of the current running procedure? > > For example: > > Public Sub Test( ) > 'do something > '... > > 'log activity (for example) > objLog.Write(Text := "bla bla bla", _ > ProcName := dontKnowWhatIsThis.GetProcName() ) > End Sub > > > Any possibility? > > Cesar > ------=_NextPart_000_0012_01C704EB.3EC322F0 > Content-Type: text/html; charset=iso-8859-1 > Content-Transfer-Encoding: quoted-printable > X-Google-AttachSize: 1758 > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> > <HTML><HEAD> > <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> > <META content="MSHTML 6.00.2800.1106" name=GENERATOR> > <STYLE></STYLE> > </HEAD> > <BODY> > <DIV><FONT face=Arial size=2>Hello,</FONT></DIV> > <DIV><FONT face=Arial size=2></FONT> </DIV> > <DIV><FONT face=Arial size=2>is there any way to get the name of the current > running procedure?</FONT></DIV> > <DIV><FONT face=Arial size=2></FONT> </DIV> > <DIV><FONT face=Arial size=2>For example:</FONT></DIV> > <DIV><FONT face=Arial size=2></FONT> </DIV> > <DIV><FONT face="Courier New" size=2>Public Sub Test( )</FONT></DIV> > <DIV><FONT face="Courier New" color=#008000 size=2> 'do > something</FONT></DIV> > <DIV><FONT face="Courier New" color=#008000 size=2> > '...</FONT></DIV> > <DIV><FONT face="Courier New" size=2></FONT> </DIV> > <DIV><FONT face="Courier New" color=#008000 size=2> 'log > activity (for example)</FONT></DIV> > <DIV><FONT face="Courier New" size=2> objLog.Write(Text := > "bla bla bla", _</FONT></DIV> > <DIV><FONT face="Courier New" size=2> > ProcName := > dontKnowWhatIsThis.GetProcName() )</FONT></DIV> > <DIV><FONT face="Courier New" size=2>End Sub</FONT></DIV> > <DIV><FONT face=Arial size=2></FONT> </DIV> > <DIV><FONT face=Arial size=2></FONT> </DIV> > <DIV><FONT face=Arial size=2>Any possibility?</FONT></DIV> > <DIV><FONT face=Arial size=2></FONT> </DIV> > <DIV><FONT face=Arial size=2>Cesar</FONT></DIV></BODY></HTML> > > ------=_NextPart_000_0012_01C704EB.3EC322F0-- No problem, I dont need the VB sintax togheter, I just needed the procedure
name. I gave a look in the thread you wrote, also works good like the code MikeMc wrote. Thanks. "rowe_newsgroups" <rowe_em***@yahoo.com> escreveu na mensagem http://groups.google.com/group/microsoft.public.dotnet.languages.vb/browse_tnews:1163186891.563352.189010@b28g2000cwb.googlegroups.com... > I don't think it anything will return "Public Sub Test" in your > example, but here's a thread that discusses a few methods: > > hread/thread/8d8ec2d0f77e7f88/c23a0015ecf89e47?lnk=gst&q=current+method+name &rnum=2#c23a0015ecf89e47 Show quoteHide quote > objLog.Write(Text :=> Thanks, > > Seth Rowe > > > Ronchese wrote: > > Hello, > > > > is there any way to get the name of the current running procedure? > > > > For example: > > > > Public Sub Test( ) > > 'do something > > '... > > > > 'log activity (for example) > > objLog.Write(Text := "bla bla bla", _ > > ProcName := dontKnowWhatIsThis.GetProcName() ) > > End Sub > > > > > > Any possibility? > > > > Cesar > > ------=_NextPart_000_0012_01C704EB.3EC322F0 > > Content-Type: text/html; charset=iso-8859-1 > > Content-Transfer-Encoding: quoted-printable > > X-Google-AttachSize: 1758 > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> > > <HTML><HEAD> > > <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> > > <META content="MSHTML 6.00.2800.1106" name=GENERATOR> > > <STYLE></STYLE> > > </HEAD> > > <BODY> > > <DIV><FONT face=Arial size=2>Hello,</FONT></DIV> > > <DIV><FONT face=Arial size=2></FONT> </DIV> > > <DIV><FONT face=Arial size=2>is there any way to get the name of the current > > running procedure?</FONT></DIV> > > <DIV><FONT face=Arial size=2></FONT> </DIV> > > <DIV><FONT face=Arial size=2>For example:</FONT></DIV> > > <DIV><FONT face=Arial size=2></FONT> </DIV> > > <DIV><FONT face="Courier New" size=2>Public Sub Test( )</FONT></DIV> > > <DIV><FONT face="Courier New" color=#008000 size=2> 'do > > something</FONT></DIV> > > <DIV><FONT face="Courier New" color=#008000 size=2> > > '...</FONT></DIV> > > <DIV><FONT face="Courier New" size=2></FONT> </DIV> > > <DIV><FONT face="Courier New" color=#008000 size=2> 'log > > activity (for example)</FONT></DIV> > > <DIV><FONT face="Courier New" size=2> > > "bla bla bla", _</FONT></DIV> > > <DIV><FONT face="Courier New" size=2> Show quoteHide quote > > ProcName := > > dontKnowWhatIsThis.GetProcName() )</FONT></DIV> > > <DIV><FONT face="Courier New" size=2>End Sub</FONT></DIV> > > <DIV><FONT face=Arial size=2></FONT> </DIV> > > <DIV><FONT face=Arial size=2></FONT> </DIV> > > <DIV><FONT face=Arial size=2>Any possibility?</FONT></DIV> > > <DIV><FONT face=Arial size=2></FONT> </DIV> > > <DIV><FONT face=Arial size=2>Cesar</FONT></DIV></BODY></HTML> > > > > ------=_NextPart_000_0012_01C704EB.3EC322F0-- > Here is one approach: Get the first frame of the stack trace.
Dim theStackTrace As New StackTrace(True) Dim theMethod As String = theStackTrace.GetFrame(0).GetMethod().ToString MessageBox.Show(theMethod) Place the code inside a method to see it get and display the method's signature. Show quoteHide quote "Ronchese" wrote: > Hello, > > is there any way to get the name of the current running procedure? > > For example: > > Public Sub Test( ) > 'do something > '... > > 'log activity (for example) > objLog.Write(Text := "bla bla bla", _ > ProcName := dontKnowWhatIsThis.GetProcName() ) > End Sub > > > Any possibility? > > Cesar That works fine for me. Thanks!
Show quoteHide quote "MikeMc" <Mik***@discussions.microsoft.com> escreveu na mensagem news:D131F3C0-175C-4DFE-96B1-E95D5879EE90@microsoft.com... > Here is one approach: Get the first frame of the stack trace. > > Dim theStackTrace As New StackTrace(True) > Dim theMethod As String = > theStackTrace.GetFrame(0).GetMethod().ToString > MessageBox.Show(theMethod) > > Place the code inside a method to see it get and display the method's > signature. > > -- > Mike McIntyre > http://www.getdotnetcode.com > > > "Ronchese" wrote: > > > Hello, > > > > is there any way to get the name of the current running procedure? > > > > For example: > > > > Public Sub Test( ) > > 'do something > > '... > > > > 'log activity (for example) > > objLog.Write(Text := "bla bla bla", _ > > ProcName := dontKnowWhatIsThis.GetProcName() ) > > End Sub > > > > > > Any possibility? > > > > Cesar Ronchese wrote:
Show quoteHide quote > Hello, You may want to look at System.Reflection. IIRC, moduleinfo.> > is there any way to get the name of the current running procedure? > > For example: > > Public Sub Test( ) > 'do something > '... > > 'log activity (for example) > objLog.Write(Text := "bla bla bla", _ > ProcName := dontKnowWhatIsThis.GetProcName() ) > End Sub > > > Any possibility? > > Cesar > ------=_NextPart_000_0012_01C704EB.3EC322F0 > Content-Type: text/html; charset=iso-8859-1 > Content-Transfer-Encoding: quoted-printable > X-Google-AttachSize: 1758 > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> > <HTML><HEAD> > <META http-equiv=Content-Type content="text/html; charset=iso-8859-1"> > <META content="MSHTML 6.00.2800.1106" name=GENERATOR> > <STYLE></STYLE> > </HEAD> > <BODY> > <DIV><FONT face=Arial size=2>Hello,</FONT></DIV> > <DIV><FONT face=Arial size=2></FONT> </DIV> > <DIV><FONT face=Arial size=2>is there any way to get the name of the current > running procedure?</FONT></DIV> > <DIV><FONT face=Arial size=2></FONT> </DIV> > <DIV><FONT face=Arial size=2>For example:</FONT></DIV> > <DIV><FONT face=Arial size=2></FONT> </DIV> > <DIV><FONT face="Courier New" size=2>Public Sub Test( )</FONT></DIV> > <DIV><FONT face="Courier New" color=#008000 size=2> 'do > something</FONT></DIV> > <DIV><FONT face="Courier New" color=#008000 size=2> > '...</FONT></DIV> > <DIV><FONT face="Courier New" size=2></FONT> </DIV> > <DIV><FONT face="Courier New" color=#008000 size=2> 'log > activity (for example)</FONT></DIV> > <DIV><FONT face="Courier New" size=2> objLog.Write(Text := > "bla bla bla", _</FONT></DIV> > <DIV><FONT face="Courier New" size=2> > ProcName := > dontKnowWhatIsThis.GetProcName() )</FONT></DIV> > <DIV><FONT face="Courier New" size=2>End Sub</FONT></DIV> > <DIV><FONT face=Arial size=2></FONT> </DIV> > <DIV><FONT face=Arial size=2></FONT> </DIV> > <DIV><FONT face=Arial size=2>Any possibility?</FONT></DIV> > <DIV><FONT face=Arial size=2></FONT> </DIV> > <DIV><FONT face=Arial size=2>Cesar</FONT></DIV></BODY></HTML> > > ------=_NextPart_000_0012_01C704EB.3EC322F0-- B. Ronchese wrote:
> is there any way to get the name of the current running procedure? System.Reflection.MethodBase.GetCurrentMethod().NameHTH, Phill W.
Make copy of arraylist
Clipboard Question newbie: is this the appropriate use of a class? Newbie: Event with Control Array accessing data from a class event in a form Has anyone managed to send email using the smtp localhost? how to create var with same name but another index? TItem, TData, etc? Generics VB.Net XML Comments and Intellisense for COM? AUTOMATIC FONTS |
|||||||||||||||||||||||