Solved

Displaying an Array in a MsgBox

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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This article will help to fix the below error for MS Exchange server 2010 I. Out Of office not working II. Certificate error "name on the security certificate is invalid or does not match the name of the site" III. Make Internal URLs and External…
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
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…
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…

717 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