none
Calendar - Getting all dates from the Calendar using VB and VS 2015 RRS feed

  • Question

  • I copied the following code from the forum and this my first time getting the dates from the calendar Start and End dates.

    I am getting these error and I need help.  How do I get to use Date.ToOADate

    Code below: and after code errors I am getting.

    Function getDates(ByVal StartDate As Date, ByVal EndDate As Date) As Variant
    
        Dim varDates()      As Date
        Dim lngDateCounter  As Long
    
        ReDim varDates(1 To CLng(EndDate) - CLng(StartDate))
    
        For lngDateCounter = LBound(varDates) To UBound(varDates)
            varDates(lngDateCounter) = CDate(StartDate)
            StartDate = CDate(CDbl(StartDate) + 1)
        Next lngDateCounter
    
        getDates = varDates
    
    ClearMemory:
        If IsArray(varDates) Then Erase varDates
        lngDateCounter = Empty
    
    End Function
    

    Error below:
    Severity	Code	Description	Project	File	Line	Suppression State
    Error	BC32059	Array lower bounds can be only '0'.	Easy Monthly Budget	C:\benoit\Simple Monthly Budget\Simple Monthly Budget\Calendar_DateRoutine.vb	27	Active
    
    
    Severity	Code	Description	Project	File	Line	Suppression State
    Error	BC30311	Value of type 'Date' cannot be converted to 'Long'.	Easy Monthly Budget	C:\benoit\Simple Monthly Budget\Simple Monthly Budget\Calendar_DateRoutine.vb	27	Active
    
    
    Severity	Code	Description	Project	File	Line	Suppression State
    Error	BC30311	Value of type 'Date' cannot be converted to 'Long'.	Easy Monthly Budget	C:\benoit\Simple Monthly Budget\Simple Monthly Budget\Calendar_DateRoutine.vb	27	Active
    
    
    Severity	Code	Description	Project	File	Line	Suppression State
    Error	BC30532	Conversion from 'Date' to 'Double' requires calling the 'Date.ToOADate' method.	Easy Monthly Budget	C:\benoit\Simple Monthly Budget\Simple Monthly Budget\Calendar_DateRoutine.vb	31	Active
    
    
    Severity	Code	Description	Project	File	Line	Suppression State
    Error	BC30311	Value of type 'Date()' cannot be converted to 'Date'.	Easy Monthly Budget	C:\benoit\Simple Monthly Budget\Simple Monthly Budget\Calendar_DateRoutine.vb	34	Active
    


    Edcal

    • Moved by Chenchen Li Monday, December 25, 2017 2:30 AM VB.NET
    Saturday, December 23, 2017 12:34 AM

All replies

  • Hi Edcal,

    This forum(Excel for developers) is for development issues related to Excel Object Model and I think your issue is more related to Visual Basic, so I would move this thread to Visual Basic forum. Thanks for understanding.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 25, 2017 2:28 AM
  • I copied the following code from the forum and this my first time getting the dates from the calendar Start and End dates.

    If this code is usable then it appears that you are using VBA, and the question should be asked at Visual Basic for Applications (VBA).

    If you are using Visual Basic .Net then you can't use the above code - it is the wrong version.   You need to find a better example, or provide a more complete description of the task.

    Monday, December 25, 2017 3:36 AM