Results 1 to 2 of 2

Thread: Between Months,Days increment by 1..

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2012
    Posts
    18

    Between Months,Days increment by 1..

    if i have 1 day..why it is increment to 1 this happens if i have month and days or include all year,months and days..year and day looks fine.2years 2 days=2 years 2days ..or if i enter 1 days only it display as 1 day but 3 months 1 day is display 3months 2 days..or 1year 2months 1 day display as 1 year 2months and 2 days...

    Code:
    Public Function RaceDate(length  As Integer ) As String
            
                 dim year As string=0
                 dim month As string=0
                dim day As string=0
                 dim ReturnString As string
    
    ReturnString=""
    
    If length = 0 then
    Return String.Empty
    end if
    
    
    
    if length >=365
    year=cstr((Math.Floor (length / 365)))
    length  =(length  Mod 365)
    
    end if
    
    If length >=30 AndAlso length<365 Then
    month =(cstr((Math.Floor(length/30))))
    length  =(length  Mod 30)
    
    end if
    
    if length<=30 Then
    day =cstr((length))
    
    end if
    
    if cint(year)>0
    
    ReturnString= year+"  Years  "
    
    end if
    
    if cint(month)>0
    
    ReturnString= ReturnString +month+" Months "
    
    end if
    
    
    
    if cint(day)>0
    
    ReturnString=ReturnString+day+"  Days "
    end if
    
    return(ReturnString)
    
    end Function

    please help..

    thanks in advance

  2. #2
    Fanatic Member AceInfinity's Avatar
    Join Date
    May 2011
    Posts
    696

    Re: Between Months,Days increment by 1..

    Your first source of conflict is that you're dealing with these values as strings. I would suggest treating them as DateTime objects before you modify any values.
    <<<------------
    Improving Managed Code Performance | .NET Application Performance
    < Please if this helped you out. Any kind of thanks is gladly appreciated >


    .NET Programming (2012 - 2018)
    ®Crestron - DMC-T Certified Programmer | Software Developer
    <<<------------

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width