Reset a controls property to the saved value (not the value proper

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I move a control around in a class module onclick event. I want to move it
back in another form so static variables are messy as I would have to put it
in a normal module. Below is a copy of a test that works fine. I would like
to know if their is a more reconized methos i Missed.

Private Sub Command0_Click()
Dim frmI As Form
Static intI As Integer
If intI Mod 2 = 0 Then
Me.Command0.Top = Me.Command0.Top - 4000
Else
Set frmI = New Form_Form4
Me.Command0.Top = frmI.Command0.Top
End If
intI = intI + 1
End Sub
 
jalewis999 said:
I move a control around in a class module onclick event. I want to move it
back in another form so static variables are messy as I would have to put it
in a normal module. Below is a copy of a test that works fine. I would like
to know if their is a more reconized methos i Missed.

Private Sub Command0_Click()
Dim frmI As Form
Static intI As Integer
If intI Mod 2 = 0 Then
Me.Command0.Top = Me.Command0.Top - 4000
Else
Set frmI = New Form_Form4
Me.Command0.Top = frmI.Command0.Top
End If
intI = intI + 1
End Sub


I never thought of doing it that way and I guess I'd be
concerned which instance of the form you retrieving the Top
property from. Actually, in this case I think just adding
4000 in the else case would do the same thing.

What I use in these situations is a module level Private
variable and save the initial Top property in the form's
Open event.
 
Back
Top