Quantcast
Viewing all articles
Browse latest Browse all 27039

Convert into vb.net

Hi,

Can anyone convert this code into VB.net functions..im new to vb.net
Code:

public Function Racedate(DateTime d1, DateTime d2)

dim monthDay as integer = {31, -1, 31, 30, 31, 30, 31, 31, 30, 31, 30,31}
dim DateTime as fromDate
dim  DateTime as toDate
dim year as  integer
dim month as integer
dim  day as integer

if (d1 >d2)
{
    fromDate = d2
    toDate = d1
}
else
{
  fromDate = d1
  toDate = d2
}

increment = 0
if (fromDate.Day > toDate.Day)
{
    increment = this.monthDay[this.fromDate.Month - 1]
}
if (increment= -1)

{
    if (DateTime.IsLeapYear(fromDate.Year))
    {
        increment = 29
    }
    else
    {
        increment = 28
    }
}
if (increment != 0)
{   
    day = (toDate.Day+ increment) - fromDate.Day;
    increment = 1
}
else
{     
    day = toDate.Day - fromDate.Day
}
if ((fromDate.Month + increment) > toDate.Month)

    month = (toDate.Month+ 12) - (fromDate.Month + increment)
      increment = 1;
}
else
{   
    month = (toDate.Month) - (fromDate.Month + increment)
    increment = 0
}
  year = toDate.Year - (fromDate.Year + increment)

 
    return year + "Year(s), " + month + " month(s), " + day + " day(s)"


thanks

Viewing all articles
Browse latest Browse all 27039

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>