vb.net - How to assign code to a code created button? -


i writing in vb 2010, did form has button "new", shows new form created code on execution time , form contains textbox , 2 more buttons. problem is, how can add code buttons b1 or b2 created? how can store data textbox in variable when click on 1 button or else. i've read post asking somthing similar here they're related vba. wrote whole code below. help.

private sub button2_click(byval sender system.object, byval e system.eventargs) handles button2.click dim f new form   dim tb new textbox     dim b1, b2 new button     dim l new label     f         .size = new system.drawing.size(220, 120)         .startposition = formstartposition.centerparent         .text = "new"         .minimizebox = false         .maximizebox = false         .controls.add(b1)         .controls.add(b2)         .controls.add(tb)         .controls.add(l)     end     l         .size = new system.drawing.size(180, 20)         .location = new point(10, 3)         .text = "label"     end     tb         .size = new system.drawing.size(180, 30)         .location = new point(10, 20)         .text = ""     end     b1         .size = new system.drawing.size(70, 30)         .location = new point(30, 50)         .text = "create"     end     b2         .size = new system.drawing.size(70, 30)         .location = new point(120, 50)         .text = "cancel"     end     f.show() 

end sub

for displaying textbox text problem, can use lambda expression handler keeps of variables in scope , allows access textbox directly.

... code above example ... b2     .size = new system.drawing.size(70, 30)     .location = new point(120, 50)     .text = "cancel" end  addhandler b1.click, sub(s, e2)                          msgbox(tb.text)                      end sub  f.show() 

Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -