Run code for all LostFocus events under an array

Posted on 2011-10-24
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 44

    Accepted Solution

    Change "0" everyplace in the sub to "Index" and it will work.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now