Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Eternal calender

Posted on 1999-01-08
4
Medium Priority
?
326 Views
Last Modified: 2012-05-04
reetings,
Imagine using either the VB-custom calender control or the Access custom calender control.  I need to know the week number of the first day of the year. Now, sometimes this number is 53
(this year), sometimes it is 52 (last year) and sometimes it is 1 (next year). But I don't want to ENTER the week number as a variable or parameter, I want some function to RETURN the
correct week number. Now the calender custom control believes the week number of the first day of the year is week number 1. The Access and VB routines calling the first day of the year
return the date or the day, provided that one enters the week number. What I believe to be looking for is some kind of eternal calender that can supply week numbers for every year, given a
week index number. (Implying the index number of a week does not equal the week number: the first week might be week 53 and so on.)
Imagine!
0
Comment
Question by:OmegaJunior
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 9

Expert Comment

by:perove
ID: 1973037
I dont understand, If you want a week number og the first day in a year why not use the format propery so it will be somthing like:

Format("01.01.1997","ww",vbMonday,vbFirstFullWeek)
not the extra parameters you can use to custom the way you want the week calculated.

This will give you the week of the 01.01 in any year you put in.

or..?
perove
0
 
LVL 18

Expert Comment

by:deighton
ID: 1973038
WILL THIS DO  

 'Text1 holds your year e.g 1999,2000 etc
    Week = Format("01-01-" & CStr(Text1), "ww", , vbFirstFourDays)


0
 
LVL 3

Author Comment

by:OmegaJunior
ID: 1973039
Greetings, deighton and perove,

Both your comments and answers helped put me on the right track. In the end, the following code gave me what I needed to know:

Public Sub WeekNumber()

Dim intWeek As Integer
Dim bytAEVT As Byte
Dim strMsg As String

strMsg = "Year and week: " & vbCrLf

bytAEVT = 0
Do While bytAEVT < 6
  intWeek = Format("01-01-" & CStr(1996 + bytAEVT), "ww", vbMonday, vbFirstFourDays)
  strMsg = strMsg & CStr(1996 + bytAEVT) & vbTab & intWeek & vbCrLf
  bytAEVT = bytAEVT + 1
Loop

MsgBox strMsg

End Sub

For this code, I used pieces of both your proposals. Therefore, I have to reject deightons answer, and ask the experts-exchange administration to divide the points between the two of you. Thank you.

Imagine!
0
 
LVL 7

Accepted Solution

by:
linda101698 earned 400 total points
ID: 1973040
I am posting the solution found by OmegaJunior so it can be saved in the previously asked questions.  I will add the points assigned to this question back to his account so he can post questions for the experts who helped him.

Linda Gardner
Customer Service @ Experts Exchange

 In the end, the following code gave me what I needed to know:

     Public Sub WeekNumber()

     Dim intWeek As Integer
     Dim bytAEVT As Byte
     Dim strMsg As String

     strMsg = "Year and week: " & vbCrLf

     bytAEVT = 0
     Do While bytAEVT < 6
       intWeek = Format("01-01-" & CStr(1996 + bytAEVT), "ww", vbMonday,
     vbFirstFourDays)
       strMsg = strMsg & CStr(1996 + bytAEVT) & vbTab & intWeek & vbCrLf
       bytAEVT = bytAEVT + 1
     Loop

     MsgBox strMsg

     End Sub

0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question