[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Displaying an Array in a MsgBox

Posted on 2006-07-07
3
Medium Priority
?
373 Views
Last Modified: 2010-04-08
I have a text file which has each persons name and their email, (eg. John Smith=john.smith@abc.com) and i have code which tests to see whether a pdf pay slip exists (eg.John Smith Pay Slip.pdf). What i want to do is display the values of the array of people who do not have a pay slip for the particlaur period, into a msgbox and the same for the ones who do. (lines ****). Any ideas of how to even assign these values to 2 different arrays which could be displayed?




For intCounter = LBound(arrFiles) To UBound(arrFiles)
            strFilename = "H:\Files\" & arrFiles(intCounter) & " " & "Pay Slip.pdf"
            If objFSO.FileExists(strFilename) Then
 *****               'store values of names who DO have files
                Set olkMessage = Application.CreateItem(olMailItem)
                With olkMessage
                    .Subject = "Pay Slip" & " for " & Mid(strFolder, 4, Len(strFolder) - 3)
                    .Body = "Here's your pay slip."
                    'Change the file name and path on the following line as desired
                    .Attachments.Add strFilename
                    .Recipients.Add arrAddresses(intCounter)
                    .Send
                End With
            Else
 *****               'store names of files which DO NOT exist
                End If
        Next
0
Comment
Question by:james_daley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 total points
ID: 17060980
Hi james_daley,

Rather than use an array it'd be far simpler to store them in two string variables.  Something like this:

    Dim strNamesWithSlips As String, _
    strnamesWithoutSlips As String
    For intCounter = LBound(arrFiles) To UBound(arrFiles)
            strFilename = "H:\Files\" & arrFiles(intCounter) & " " & "Pay Slip.pdf"
            If objFSO.FileExists(strFilename) Then
                strNamesWithSlips = strNamesWithSlips & arrFiles(intCounter) & vbCrLf
                Set olkMessage = Application.CreateItem(olMailItem)
                With olkMessage
                    .Subject = "Pay Slip" & " for " & Mid(strFolder, 4, Len(strFolder) - 3)
                    .Body = "Here's your pay slip."
                    'Change the file name and path on the following line as desired
                    .Attachments.Add strFilename
                    .Recipients.Add arrAddresses(intCounter)
                    .Send
                End With
            Else
                strNamesWithoutSlips = strNamesWithoutSlips & arrFiles(intCounter) & vbCrLf
            End If
    Next
    MsgBox "The following staff have pay slips: " & strNamesWithSlips & "The following staff do not have payslips: " & strNamesWithoutSlips

Cheers!
0
 
LVL 1

Author Comment

by:james_daley
ID: 17070632
Thanks very much. Once again you've come to the rescue!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 17071335
You're welcome.  Always happy to be able to help out.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many people use more than one email account and so it becomes difficult for them to manage them when they use separate accounts,  so, in this article, I have shared an easy way to add Other Mail Accounts in your Google Inbox. It helps to combine all…
Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question