DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Overflow

  1. #1
    Gillian Maloney Guest

    Overflow


    I am getting an overflow message when I try to add two months onto a date
    to give a new date:

    Dim DueDate as Date
    Dim VarLastDate as Date
    varLastDate = Data1.Recordset("LastDate")
    DueDate = VarLastDate + 00/02/00 'It debugs here - Overflow

    Any Suggestions of what I am doing wrong
    Thanks for your help
    Gillian


  2. #2
    David Phillips Guest

    Re: Overflow

    Gillian -

    In your calculation, there is nothing that tells VBA that your two months
    (00/02/00) is actually supposed to be a date. When VBA sees the 00/02/00, it
    thinks it is supposed to divide the numbers - 0 divided by 2, divided by 0 - and
    this is triggering the overflow error.

    There's a number of ways you could do the calculation - here's one way, using
    the DateAdd function:

    DueDate = DateAdd("m", 2, VarLastDate)

    Hope this helps!
    David Phillips
    dpdave0@earthlink.net


    "Gillian Maloney" <GMaloney@pbs.ie> wrote in message
    news:39522863$1@news.devx.com...
    >
    > I am getting an overflow message when I try to add two months onto a date
    > to give a new date:
    >
    > Dim DueDate as Date
    > Dim VarLastDate as Date
    > varLastDate = Data1.Recordset("LastDate")
    > DueDate = VarLastDate + 00/02/00 'It debugs here - Overflow
    >
    > Any Suggestions of what I am doing wrong
    > Thanks for your help
    > Gillian
    >




  3. #3
    Ian King Guest

    Re: Overflow

    Hi Gillian

    The problem is when you add to a date you can only add days.

    For what you want to do use

    DueDate = DateAdd("m", 2, VarLastDate)

    regards

    Ian

    ** invalid email address, change dk to denmark

    homepage http://www.kingsoft-denmark.com/


    Gillian Maloney <GMaloney@pbs.ie> wrote in message
    news:39522863$1@news.devx.com...
    >
    > I am getting an overflow message when I try to add two months onto a date
    > to give a new date:
    >
    > Dim DueDate as Date
    > Dim VarLastDate as Date
    > varLastDate = Data1.Recordset("LastDate")
    > DueDate = VarLastDate + 00/02/00 'It debugs here - Overflow
    >
    > Any Suggestions of what I am doing wrong
    > Thanks for your help
    > Gillian
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center