Public Sub getMinPeriod_MaxPeriod_TotalInstallPlanPeriods(passedYearsGoverned As String, _ returnMinAgreementPeriod As Long, _ returnMaxAgreementPeriod As Long, _ returnNumberOfPeriods As Long, _ returnIs2017Included As Boolean) ' this routine will be passed the years governed string from the install plan ' the try to pick out the min year, max year and then calculate the number of periods. ' ' basically it will create the years one by one starting at 1960. Then it will see if that year ' exist in the string. If it does it will make that year eithere the oldest found so far or ' the newest found so far. At the end of looping thru the years we should have the min and max ' Dim wkYearStr As String Dim wkYearNum As Long Dim wkMinPeriod As Long Dim wkMaxperiod As Long ' wkMinPeriod = 9999 wkMaxperiod = 0 returnIs2017Included = False ' returnIs2017Included = False ' For wkYearNum = 1960 To 2017 ' wkYearStr = Trim(Str(wkYearNum)) If InStr(1, passedYearsGoverned, wkYearStr) Then ' compare min If wkYearNum < wkMinPeriod Then wkMinPeriod = wkYearNum End If ' compare max If wkYearNum > wkMaxperiod Then wkMaxperiod = wkYearNum End If ' is 2017 included If wkYearNum = 2017 Then returnIs2017Included = True End If ' End If ' Next wkYearNum ' ' If none found them all must be returned as zero ' If wkMinPeriod = 9999 Then wkMinPeriod = 0 End If ' ' calculate the number of periods ' returnMinAgreementPeriod = wkMinPeriod returnMaxAgreementPeriod = wkMaxperiod returnNumberOfPeriods = wkMaxperiod - wkMinPeriod + 1 ' End Sub
From novice to tech pro — start learning today.