Zorder doing strange things

K

Ken Soenen

Can anybody explain what's going on here ?

Put two listboxes and two commandbuttons on a form and
partially overlap the two listboxes. The code below should
alternately bring to the front and then to the rear Listbox2.


Private Sub CommandButton1_Click()
ListBox2.ZOrder (0)
End Sub

Private Sub CommandButton2_Click()
ListBox2.ZOrder (1)
End Sub

Here is what I'm seeing:

1. Run the form and it works fine. (or it may not work)
2. close the form
3. add a blank(if necessary) to the code and do a SAVE
4. run the form again and now it DOES NOT Work.
5. you can keep doing this and it alternates from WORKING to
NOT WORKING every time you do a SAVE.

I'm using Excel 2003. WORD does the same thing.
 
D

Dave Peterson

Maybe just redrawing the userform would help:


Option Explicit
Private Sub CommandButton1_Click()
me.ListBox2.ZOrder 0
Me.Repaint
End Sub
Private Sub CommandButton2_Click()
me.ListBox2.ZOrder 1
Me.Repaint
End Sub
 
D

Dave Peterson

It was enough to make it work ok for me.

Maybe adding doEvents would help???
 
K

Ken Soenen

Dave,
Were you actually able to alternately make it work and fail by using
the SAVE from the menu bar? This seems really crazy.!!!
ken
 
D

Dave Peterson

I didn't use the save at all. I added me.repaint and it worked fine.



Ken said:
Dave,
Were you actually able to alternately make it work and fail by using
the SAVE from the menu bar? This seems really crazy.!!!
ken
 

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