Run code for all LostFocus events under an array

Posted on 2011-10-24
Medium Priority
Last Modified: 2012-05-12
I have the following code for a LostFocus event on my vb6 form.  As you can see it is on a textbox control named MR6Date(0)

I have an array of MR6Date(0) to MR6Date(19)

Is it possible to have this code run for all LostFocus events for this array?
Private Sub MR6Date_LostFocus(Index As Integer)

If Not MR6Date(0) = "" Then
    If IsDate(MR6Date(0)) = False Then
    MsgBox "Enter a Valid Date in the Correct Format", vbOKOnly, "Date"
    MR6CCM(0).Enabled = False
    MR6CSW(0).Enabled = False
    Exit Sub
    End If
Text15 = Format(MR6Date(0), "mm/dd/yyyy")

End If
End Sub

Open in new window

Question by:al4629740
1 Comment
LVL 50

Accepted Solution

Martin Liss earned 2000 total points
ID: 37022307
Change "0" everyplace in the sub to "Index" and it will work.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

621 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