Create a function TotalDaysMonth(intYear, intMonth, strIndOrCum) in both VB and Matlab to calculate the cumulative days or number of days in a given month, depending on inputs, by employing array vector in VB or a vector matrix in Matlab.
------------- In VB:
Function TotalDaysMonth(intYear, intMonth, strIndOrCum)
DaysInMonth = Array(31, 28, 31, 30, ...)
. . .
If strIndOrCum = "I" Then
. . .
ElseIf strIndOrCum = "C" Then
. . .
Else
. . .
End If
. . .
End Function
-------------- In Matlab:
Function TotalDays = TotalDaysMonth(intYear, intMonth, strIndOrCum)
DaysInMonth = [31, 28, 31, 30, ...];
. . .
if strIndOrCum == 'I'
. . .
elseif strIndOrCum = 'C'
. . .
else
. . .
end
. . .
end
Note:
1. Matlab: Starting index of a row vector is 1. VB: Starting index of a row vector = 0.
2. You need to call function isLeapYear(intYear) to adjust the output if necessary.
1.2. By having the input as one line of string, combining the year, month, and day; with the expected I/O: (with {xxx} is the input for the prompt)
====================
Enter date: {2012/03/15}
Total day passed in 2012 before 3/15 = 74 days