vb.net - Passing the value from curElement to another private sub -


hi have each inside private sub , want pass value of cuelement private sub.

dim theanchorscollection htmlelementcollection = nothing theanchorscollection = webbrowser1.document.getelementsbytagname("a") each curelement htmlelement in theanchorscollection             curelement.style = "style code here"             addhandler curelement.click, addressof onaclick next 

and want pass value other sub:

 private sub onaclick(sender object, e htmlelementeventargs)     dim endereco string     endereco = curelement.getattribute("href").tostring()     'do other things end sub 

i want know if in sub can use value of other's curelement.

never mind, found answer (sender) variable wanted.

as found in msdn forums

as use addhandler subscribe given event, pass required arguments of event procedure addressof delegates , argument signature "must" same event's.

a demo:

public class form1      private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load         addhandler button1.mousedown, addressof btn_mousedown     end sub      sub btn_mousedown(byval sender object, _     byval e system.windows.forms.mouseeventargs)         msgbox(e.button.tostring)     end sub end class 

using addhandler, we're subscribing mousedown event of button, , specifiying procedure gonna called on follow. passed arguments object(sender) , mouseeventargs (e), , can use in event sub above. (eg: mousebutton down.)


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -