Solved

Eternal calender

Posted on 1999-01-08
4
317 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
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 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

867 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now