excel vba - How do I move two tiled modal forms together? -


I have two model users, FRMA and FRMB. I would like to tile the forms and when I want to move the top size , Then I would like other forms to follow it, remaining in tile position as they are tied together.

Opening a button in FrmA is frmB. When FRMB opens, it is active and the user interacts with it, while frmA is visible, but the user can not be transferred or accessed. It's all hoped.

  'This is part of the FRMA command button to open frmb' Load, start and show form B. Send coordinates of form A set form B = new FRMB load form BDIM IAlLight integer dense IA_Top Let's start the integer IA_Left = Me.Left iA_Top = Me.Top 'formB and pass the current state of forma byRef (used by active event) if not formB.bInitialize (vbFalse, iA_Top, iA_Left) then Err.Raise Glandle_Error IA_Top & lt; & Gt; -1 then miA_Top = iA_Top end if iA_Left & lt; & Gt; -1 Then the miA_Left = iA_Left End if formB.Show   

I have detected that to activate the userform, tile the frmB on frmB (slightly lower and right) to activate the event. Then when frmB is closed, then I pass back the origin of the frmA to the left and above so that after it is restarted, it will appear in its original state.

  'This is from frmB activate event' variable miA_Left and miA_Top are set in the initialize event through 'optional variable' passed above the code Private sub UserForm_Activate () error resume Next to the miA_Left & lt; & Gt; -1 Then Me.Left = miA_Left + 15 End if the miA_Top & lt; & Gt; -1 Then me.Top = miA_Top + 15 Else Me.op = Round ((application.Top + Application.Height) / 2 - Me.Height / 2, 0) End if the end sub 'This is the frmB layout event from the Private sub UserForm_Layout () debug Print "layout left" & amp; Me.Left if miA_Left & lt; & Gt; -1 and M AOHOPP & lt; & Gt; -1 'Then' in this case, this is correct and the next line is frmA.Left = Me.Left - 10frmA.Top = Me.Top - 10 End if End Sub   

When I Debug layout events, before the first assignment, I put my cursor over the frmA. The top and it says "Object variable is not set" but then it makes the revenue to hand over numbers to FMAA. However, it does not change the position of frmA. The form class name is actually the FRMA, but when I created a variable to generate the form, then I

  the demat formrier to frmA The set was used as a forma A = New frmA   

However, formA will not be within the scope of frmb, so I do not think I can refer to that variable.

What I need to do is, when the user draws around the frmB, I want to follow it to frmA, balance the tile I do not know how to change. Top and. The length of FrmA is frmB active. I have tried various statements in frmB's active and layout events, but I am not sure how FRMA approaches directly from the FRMB.

Thank you!

To change the status of form A using the form B can do.

Such a form A is called frmA )

  Personal sub UserForm_Layout () frmA.Top = Me.Top - 15 frmA. Left = Me.Left - 15 End sub    

update form 'normal' usage

As you comment in your comment Indicates, it is useful when using the instances of the form. To show more than one example, the 'normal' method only refers to the names of the base form class themselves.
Examples if we have two forms: frmA and frmb , with frmA in which the command button and frmb There is no control, we can demo the following type of tile code (code below has the entire contents of the module)

  code in a standard module, frmA option clear sub-demo () to show frmA.Show vbModal End sub   

.

  'Code' in the frmA option, all private commands commandbutton 1_Click () frmB.Show vbModal End Sub   

.

  'code in FMB option private sub userform_activate (frmB.Top = m) + 15 FMB. Lv = mi Late + 15 & Sub Private All Userform_layout (FMA) Tap = mi Top - 15 FMA Lie = m Late - 15nd Subserved    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -