Though you could (throught reflection or by providing an explicit argument)
this would be really IMO a bad thing to do (what if you want then to call
from a third place or if you change the caller name or whatever).
My personal preference would be to split this having :
- a method that contains the common code
- a method that calls this common code + what is specific to the "new" case
- a method that calls this common code + what is specific to the "click"
case
Then just call the correct method from the constructor and the click event.
It models closely the situation you have that is you want to call common
code from both places but each place will call its own broadest work that in
turn calls common work to be done (instead of having each place calling
common code and deciding in this common code that you should finally do only
this or that because you have been called from a particular location)...
--
Patrice
"Marc R." <Ma***@discussions.microsoft.coma écrit dans le message de news:
5C**********************************@microsoft.com...
Hello,
I have a function "DoSomething" that it is called from the constructor and
also from the code like in a click event. Is there a way to know, from my
DoSomething function, who has call this function? ex.:
Sub DoSomething
If Call = "New" then
'I am from Sub New
Else
'I am from some where else
End IF
End Sub
Hope that I am clear