This is my code, and thoughs on this error:
Conversion from string "MM/yyyy" to type 'Date' is not validerror:

    Public Function AddNextMonthDue(ByRef OldNMD As String, ByRef MonthsToAdd As String) As String
        Dim dOldNMD As Date
        Dim dNewNMD As Date
        Dim sOldNMD As String
        If Len(OldNMD) = 4 Then ' MMDD format
            sOldNMD = "20" & Right(OldNMD, 2) & Left(OldNMD, 2) & "01"
        Else
            sOldNMD = OldNMD ' YYYYMMDD format
        End If
        dOldNMD = CDate(Mid(sOldNMD, 5, 2) & "/1/" & Left(sOldNMD, 4))         

        dNewNMD = DateAdd(Microsoft.VisualBasic.DateInterval.Month, CShort(MonthsToAdd), dOldNMD)
        AddNextMonthDue = Format(CDate(dNewNMD), "MMyy")

    End Function

A string of the form "MM/yyyy" is not a valid date. A valid date has day, month and year parts.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.