Solved

Eternal calender

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

776 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