textbox - How can I move (displace) TextBoxes created during runtime, referring to them by name? VBA -
so have created user form take input user create tool in evaluation of financial investments job. user form takes account possible revenues , expenses generated investment, number of years investment useful. added 3 buttons, 1 creates new revenue row, creates new expenses row , last new years column, giving me 2 matrices of rev x years , expenses x years. if need more details let me know!
the small "+" buttons seen add rows of revenues or expenses or columns of years. problem when add row of revenues have displace expenses down, created in run-time. approach has been use controls collection , name of text box (which have made matrix: e1y1, e2y2, e1y2, e2y2,... , forth) using each statements , couple of loops. program runs , compiles properly, things shifting down labels , frames, outside each , loops code. i'm attaching relevant code if there's else need let me know, suuuper appreciated!!
private sub movecontrols() dim ctl control dim cell textbox let y = 0 let e = 0 each ctl in me.controls if typeof ctl textbox cell = ctl while y < years while e < expenses 'names of small cells in grid ' expense values if cell.name = "e" & e & "y" & y cell.top = cell.top + 19 end if 'names of larger cells on left under ' "expenses" expense names if cell.name = "expenses" & e cell.top = cell.top + 19 end if e = e + 1 loop y = y + 1 loop end if next ctl 'this part of code executes revenuesframe.top = revenuesframe.top + 19 expenseslbl.top = expenseslbl.top + 19 addxpsbutton.top = addxpsbutton.top + 19 end sub
Comments
Post a Comment