将多个消息框值添加到 vba 中的单个消息框 [英] adding multiple messgeboxes values to single messagebox in vba

查看:52
本文介绍了将多个消息框值添加到 vba 中的单个消息框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码,我可以在每个外循环结束时显示消息.我想在假设数组或类似结构的一些列表中捕获所有这些消息,然后最后想将这些消息中的每一条显示到一个 msgbox 中.如果有人可以帮助我,我将不胜感激.谢谢.

I have this code with me where i can display the message when every outer loop ends. I want to catch all these messages in suppose array or soome list like structure and then at the end want to display each of these messages into one msgbox. Would appreciate if someone could help me. Thanks.

For Each objNavFolder In objNavGroup.NavigationFolders
    SkippedItemCounter = 0
    If oItems.Count = 0 Then
        MsgBox "No Appointments items in " & objNavFolder.DisplayName & "'s folder"
    Else
        NextRow = NextRow + 1
        For Each MyItem In oItems
             If MyItem = "" Then
                 SkippedItemCounter = SkippedItemCounter + 1
             End If
             'some code here
        Next 
        Set objExpl = _colExpl.Add(objFolder, olFolderDisplayNormal)
        NextRow = NextRow - 1
    End If
    MsgBox "No. of items= "&SkippedItemCounter&"skipped from"&objNavFolder.DisplayName&""
Next 
End If
End If
End If

推荐答案

不要调用 msgboxes,而是创建一个 String 并继续添加消息 - 在代码末尾 msgbox(yourString)

instead of calling msgboxes, create a String and keep adding the messages - at the end of code msgbox(yourString)

例如在主子之前声明一个字符串

for example decalare a string before the main sub

Dim yourFinalMessage As String ' or Dim yourFinalMessage$

代替

MsgBox "No Appointments items in " & objNavFolder.DisplayName & "'s folder"

yourFinalMessage = yourFinalMessage & vbCrLf & & _ 
             "No Appointments items in " & objNavFolder.DisplayName & "'s folder"

继续这样做直到循环结束.

keep doing this until the loop ends.

在循环结束时说

msgbox YourFinalMessage 

这篇关于将多个消息框值添加到 vba 中的单个消息框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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