We Recommend

Visual Basic 2008 Programmer's Reference Visual Basic 2008 Programmer's Reference
Visual Basic Orcas Programmer's Reference is a language tutorial and a reference guide to the upcoming Orcas release of Visual Basic. The tutorial provides basic material suitable for beginners but also includes in-depth content for more advanced developers.


Posted By

corydeppen on 05/07/07


Tagged

access vba 2003 vb


Versions (?)


Determine work day number within month


Published in: Visual Basic 


  1. Function workdayNumber(TheDate As Date) As Byte
  2.  
  3. ' Determines the work day number within a month
  4.  
  5. Dim tempDate As Date
  6. Dim tempWeekDay As Byte
  7.  
  8. ' Start with the first day of the month
  9. tempDate = CDate(Format(TheDate, "m/1/yyyy"))
  10.  
  11. Do While Month(tempDate) = Month(TheDate)
  12. tempWeekDay = Weekday(tempDate)
  13. If (tempWeekDay > 1) And (tempWeekDay < 7) Then
  14. workdayNumber = workdayNumber + 1
  15. If tempDate = TheDate Then
  16. Exit Function
  17. End If
  18. End If
  19. tempDate = tempDate + 1
  20. Loop
  21.  
  22. End Function

Report this snippet 

You need to login to post a comment.