Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Modeless Userform Not Displaying

I'm not sure why you have a DoEvents call inside
the loop below but I didn't find it necessary.


If your form to substitute the statusbar is merely to display something like
"Wait, processing...", indeed only the one DoEvents just after showing the
form is all you need. But if you want to inform user of progress, eg
percentage done, you will probably need DoEvents each time you write the new
update to the form within the loop. FWIW, changing the form's caption
wouldn't need DoEvents.

DoEvents is a relatively slow process, if you update the form with DoEvents
in each loop you might double (or more) the overall length of your routine.
However limiting to 100 updates, as in the example, would barely impact the
overall time of a long loop.

Be aware that DoEvents also enables user to trigger other processes within
the loop, a candidate is attempting to close the form and hence the trap in
the UserForm_QueryClose event in the example (though unlikely an issue with
your single DoEvents).

Regards,
Peter T

"tc69" wrote in message
...
Bob Flanagan's Repaint suggestion worked but only partially. Often it

would
not finish displaying the message (about 20 characters).

I tried adding a single DoEvents call right after my Show vbModeless call
and it worked every time. Adding a single DoEvents call right after my

Hide
call also helps it clear itself before subsequent code executes as well.

I'm
not sure why you have a DoEvents call inside the loop below but I didn't

find
it necessary. Like I said, my Form simply displays a message in a Label
control. It has no UserForm or Label Control Events implemented.

Thanks!

"Peter T" wrote:

Typically would normally want to show the form as modal if it's merely

to
display progress, but perhaps modeless depending on what you are doing.

Try
something like this, limiting the number of times you update the form

and in
particular use DoEvents to a minimum.

Sub test()
Dim frm As UserForm1, lab As MSForms.Label
Dim i As Long
Dim nTo As Long, nPct As Long, nNextUpdate As Long

nTo = 1000
Set frm = New UserForm1
frm.Show vbModeless
Set lab = frm.Label1
frm.gbCodeRunning = True

DoEvents

For i = 1 To nTo
Range("A1").Formula = "RAND()"
If i = nNextUpdate Then
nPct = nPct + 1
nNextUpdate = nPct * nTo / 100
lab.Caption = nPct - 1 & "% done " & i & " \ " & nTo & " "
DoEvents
If Not frm.gbCodeRunning Then
Exit For
End If
End If
Next

frm.gbCodeRunning = False

frm.Hide
Unload frm ' not necessary with example as written but triggers

QueryClose
Set frm = Nothing

End Sub

' in the form module
Public gbCodeRunning As Boolean

Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If gbCodeRunning Then
' in case user clicks little x don't allow close form
Cancel = True

' maybe allow user to cancel
If MsgBox("Do you want to Cancel", vbYesNo) = vbYes _
Then gbCodeRunning = False
End If
End Sub

Regards,
Peter T

"tc69" wrote in message
...
I have a UserForm with a single Label Control that I do a .Show

vbModeless
on
to display status messages. However, it only displays the the

UserForm's
Title Bar and Borders. The contents appear as solid white, unless I'm

in
Debug mode or I've done a MsgBox after I called .Show!?! Even then,

as
soon
as I proceed with execution it'll go back to the blank white

contents.
If I
choose not to .Hide it after I'm done with it, it'll show after my

Macro
has
stopped!?! I've played with Application.ScreenUpdating and

..Interactive.
Suggestions? Thanks!

P.S. I don't want to use the Status Bar because it's not very

noticeable
and
I still want Excel's normal Status messages to show.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
modeless userform problem AD108 Excel Programming 2 December 24th 06 05:14 AM
Modeless userform hngo New Users to Excel 2 July 13th 05 09:23 AM
Modeless Userform problem Robin Hammond[_2_] Excel Programming 0 September 2nd 04 02:29 PM
modeless userform jacob Excel Programming 1 May 4th 04 02:53 PM
Modeless userform jacob[_3_] Excel Programming 2 September 29th 03 08:02 PM


All times are GMT +1. The time now is 06:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"