状态栏进度表未显示消息 [英] Status Bar Progress Meter not showing messages

查看:163
本文介绍了状态栏进度表未显示消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经进行了一些研究和开发工作,发现为我想使用的类型。



我遇到的问题是进度条不会在状态栏中移动,也不会移动第一个和最后一个消息,即工作和提取的所有文件未显示。我在哪里出错?

  Private Sub btnFetchFiles_Click()

Dim j As Integer

iRow = 20
fPath =\\c\s\CAF1\Dragon Mentor Group\Dragon Scripts\Current\April 2015
如果fPath< ;> 然后

'使StatusBar可见
Application.DisplayStatusBar = True
设置FSO = New Scripting.FileSystemObject
'第一个消息
Application.StatusBar =字符串(5,ChrW(9609))& 工作...
如果FSO.FolderExists(fPath)<> False Then
'Second Message
Application.StatusBar = String(5,ChrW(9609))& 工作...
设置SourceFolder = FSO.GetFolder(fPath)
'第三个消息
Application.StatusBar = String(5,ChrW(9609))& 工作...
IsSubFolder = True
'第四个消息
Application.StatusBar = String(5,ChrW(9609))& 仍然工作...
调用DeleteRows
如果AllFilesCheckBox.Value = True然后
'第五个消息
Application.StatusBar = String(5,ChrW(9609))& 还工作...
调用ListFilesInFolder(SourceFolder,IsSubFolder)
调用ResultSorting(xlAscending,C20)
调用FormatCells
Else
调用ListFilesInFolderXtn(SourceFolder ,IsSubFolder)
调用ResultSorting(xlAscending,C20)
调用FormatCells
End If
'第六个消息
Application.StatusBar = String(5,ChrW(9609 ))& 仍然工作...
lblFCount.Caption = iRow - 20
'第七个消息
Application.StatusBar = String(5,ChrW(9609))& 几乎完成...
Else
MsgBox选择的路径不存在!! &安培; vbNewLine& vbNewLine& 选择正确的一个,再试一次!!
结束如果
Else
MsgBox文件夹路径不能为空! &安培; vbNewLine& vbNewLine&
End If
'Eigth Message
Application.StatusBar = String(5,ChrW(9609))& 所有文件提取...
'放弃StatusBar
Application.StatusBar = False
End Sub


解决方案

您没有看到它们的原因是它们立即被下一个 StatusBar 消息。



以此为例:

 'Eigth Message 
Application.StatusBar = String(5,ChrW(9609))& 所有文件提取...
'上一条消息显示为零秒后,
'放弃StatusBar
Application.StatusBar = False

您正在显示消息并立即擦除。



您的第一条消息的想法相同。发生在之间的语句可能在不到一毫秒的时间内执行,这样您的第一条消息将显示多长时间;所以你看不到它。在某种程度上,这是完全有意义的,因为如果进度是即时的,则不需要显示进度计。



您提供的链接使用 Application.Wait 语句来强制程序在显示进度时等待。但这只是为了说明目的;你永远不会像这样故意减慢你的实际程序。






进度条不会越来越长的原因是您明确地告诉它保持相同的长度:

  String(5,ChrW(9609))

将始终返回五个字符长的进度条:▉▉▉▉▉您提供的链接使其从5增长到10到15.


I'm trying to put together a 'Status Bar Progress Meter' to help the user when loading a lengthy macro.

I've carried out some research and found this to be the type that I'd like to use.

The problem I have is that the progress bar doesn't move across the Status Bar and the first and last messages i.e. "Working" and "All Files Extracted" are not shown. Where have I gone wrong?

Private Sub btnFetchFiles_Click()

    Dim j As Integer

        iRow = 20
        fPath = "\\c\s\CAF1\Dragon Mentor Group\Dragon Scripts\Current\April 2015"
        If fPath <> "" Then

            ' make StatusBar visible
            Application.DisplayStatusBar = True
            Set FSO = New Scripting.FileSystemObject
            'First Message
            Application.StatusBar = String(5, ChrW(9609)) & " Working..."
            If FSO.FolderExists(fPath) <> False Then
                'Second Message
                Application.StatusBar = String(5, ChrW(9609)) & " Working..."
                Set SourceFolder = FSO.GetFolder(fPath)
                'Third Message
                Application.StatusBar = String(5, ChrW(9609)) & " Working..."
                IsSubFolder = True
                'Fourth Message
                Application.StatusBar = String(5, ChrW(9609)) & " Still Working..."
                Call DeleteRows
                If AllFilesCheckBox.Value = True Then
                'Fifth Message
                Application.StatusBar = String(5, ChrW(9609)) & " Still Working..."
                    Call ListFilesInFolder(SourceFolder, IsSubFolder)
                    Call ResultSorting(xlAscending, "C20")
                    Call FormatCells
                Else
                    Call ListFilesInFolderXtn(SourceFolder, IsSubFolder)
                    Call ResultSorting(xlAscending, "C20")
                    Call FormatCells
                End If
                'Sixth Message
                Application.StatusBar = String(5, ChrW(9609)) & "Still Working..."
                lblFCount.Caption = iRow - 20
                'Seventh Message
                Application.StatusBar = String(5, ChrW(9609)) & "Almost Done..."
            Else
                MsgBox "Selected Path Does Not Exist !!" & vbNewLine & vbNewLine & "Select Correct One and Try Again !!"
            End If
        Else
            MsgBox "Folder Path Can not be Empty !!" & vbNewLine & vbNewLine & ""
        End If
                'Eigth Message
                Application.StatusBar = String(5, ChrW(9609)) & "All Files Extracted..."
       'Relinquish the StatusBar
        Application.StatusBar = False
    End Sub

解决方案

The reason you don't see them is that they are immediately overwritten by the next StatusBar message.

Take this for example:

   'Eigth Message
   Application.StatusBar = String(5, ChrW(9609)) & "All Files Extracted..."
   'After the previous message has displayed for zero seconds, 
   'Relinquish the StatusBar
   Application.StatusBar = False

You're displaying a message and erasing it right away.

Same idea for your first message. The statements that occur in between probably execute in less than a millisecond, so that's how long your first message will show; hence you don't see it. Which, in a way, makes total sense, because there is no need for a progress meter to be displayed if progress is instantaneous.

The example in the link you provide uses Application.Wait statements to force the program to wait while the progress bare is being shown. But that's just for illustration purposes; you would never slow down your actual program on purpose like that.


The reason the progress bar isn't getting longer and longer is that you are explicitly telling it to stay the same length:

String(5, ChrW(9609)) 

will always return a progress bar that is five characters long: ▉▉▉▉▉. The example in the link you provide makes it grow from 5 to 10 to 15.

这篇关于状态栏进度表未显示消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆