Solved

Displaying an Array in a MsgBox

Posted on 2006-07-07
3
369 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 500 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
In this step by step procedure, you will come to know the details of creating an Outlook meeting in 2007, 2010, 2013 & 2016.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

726 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