1
Answer

Visual Basic 6.0 to C sharp .Net Online Converter Tool

Photo of David Smith

David Smith

10y
614
1
Can someone point me to a good website online converter tool from Visual Basic 6.0 to C sharp

Answers (1)

0
Photo of Vulpes
NA 98.3k 1.5m 12y
Here is some basic code to work out the number of working days (Monday to Friday) in any given month and year:

      int[] daysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
      int month = 6; // June
      int year  = 2012;
      if (DateTime.IsLeapYear(year)) daysInMonth[1] = 29;
      DateTime dt = new DateTime(year, month, 1);
      int workingDays = 0;
      
      for(int i = 1; i <= daysInMonth[month - 1]; i++)
      {
         if(dt.DayOfWeek != DayOfWeek.Sunday && dt.DayOfWeek != DayOfWeek.Saturday) workingDays++;
         dt = dt.AddDays(1);
      }

      label1.Text = workingDays.ToString(); // 21

If you want to regard Saturday as a working day, then just change this line:

    if(dt.DayOfWeek != DayOfWeek.Sunday && dt.DayOfWeek != DayOfWeek.Saturday) workingDays++;

to this:

    if(dt.DayOfWeek != DayOfWeek.Sunday) workingDays++;