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

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
 
M

Marshall Barton

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top