Friday, June 24, 2005
Rule 16: StatusBar
Use the Status bar to report information back to the user whilst code is being executed.
For example, if several files or database queries are being run, then
will display a message on the status bar.
Will remove the value on the status bar.
However, we are then back with the issue of nested calls.
Its much better to create two utility functions, with the call, PushStatusMessage, and PopStatusMessage that creates a stack of status messages.
For example, if several files or database queries are being run, then
Application.StatusBar = "Loading file 1 ..."
will display a message on the status bar.
Application.StatusBar = False
Will remove the value on the status bar.
However, we are then back with the issue of nested calls.
Its much better to create two utility functions, with the call, PushStatusMessage, and PopStatusMessage that creates a stack of status messages.
Private Const MaxStatusMessage As Integer = 100
Dim StatusMessages(MaxStatusMessage) As String
Dim StatusMessageCount As Integer
Public Sub PushStatusMessage(message As String)
If StatusMessageCount = MaxStatusMessage Then
MsgBox "Status message stack is full"
Exit Sub
End If
StatusMessages(StatusMessageCount) = message
StatusMessageCount = StatusMessageCount + 1
Application.StatusBar = message
End Sub
Public Sub PopStatusMessage()
If StatusMessageCount = 0 Then
'MsgBox "Status message stack is empty"
Exit Sub
End If
StatusMessageCount = StatusMessageCount - 1
If StatusMessageCount = 0 Then
Application.StatusBar = False
Else
Application.StatusBar = StatusMessages(StatusMessageCount - 1)
End If
End Sub
Public Sub Test()
PushStatusMessage ("Test 1")
PushStatusMessage ("Test 2")
PopStatusMessage
PopStatusMessage
End Sub
Subscribe to Posts [Atom]