I'm new with VB and I need to write a code that will calculate days starting from a start date (x), adding (y) days per month till the present date (z), subtracting given days (i) and finally giving remain days (j). Can anyone please given some examples.

Is this a school project ?

If so how far have you got ?

I'm new with VB and I need to write a code that will calculate days starting from a start date (x), adding (y) days per month till the present date (z), subtracting given days (i) and finally giving remain days (j). Can anyone please given some examples.

u can use dateadd() and datediff() functions to manipulate date data type
above funtions are add two date and subtract one date from other date
but here datediff function does not give proper ansr.

Is this a school project ?

If so how far have you got ?

This is not a school project. I've designed a Data Base using MS ACCESS for my work and I need to create something that will calculate more or less the exact leave credit days of each person at work. That is why I want to use VB for that purpose. Please help me with any suggestion or examples that I can use. By the way, I' new with the VB. Please help me.

my email is [EMAIL="snipped"]snipped[/EMAIL].

Thanx

My apologies - the post sounded like a school project. Where are the dates and day coming from, fileds, forms, etc? What are you going to do with result, display or store in a field ?

I'll try and suggest some code this evening.

My apologies - the post sounded like a school project. Where are the dates and day coming from, fileds, forms, etc? What are you going to do with result, display or store in a field ?

I'll try and suggest some code this evening.

The dates and day are coming from :

1. Starting Date(x) : The date when the member started working,
2. Adding days per month(y) : Are days that are leave days added per month to each member,
3. Present Date(z) : Is the present date,
4. Given Days(i) : Are days that the member take when going on leave ,
5. Remain Days(j) : Are days that the member will have left after taking a leave.

The result I want to store and desplay in field that will deplay the total leave credit days a member has on the form that will deplay his/her personal details.

Thanx again.

The dates and day are coming from :

1. Starting Date(x) : The date when the member started working,
2. Adding days per month(y) : Are days that are leave days added per month to each member,

This you can easily calculate from the start date to the current date. I assume you can handle this one. Look at the months for your calculations.

3. Present Date(z) : Is the present date,

Yes, the function Date() will return the present date

4. Given Days(i) : Are days that the member take when going on leave ,

Is this a value types in, read from the DB? Either way, it gets specified somehow.

5. Remain Days(j) : Are days that the member will have left after taking a leave.

Now subtract the value in #4 from the value in #2

The result I want to store and desplay in field that will deplay the total leave credit days a member has on the form that will deplay his/her personal details.

From the above you have:
Total leave days accumulated
Leave days taken
Leave days left

I'd recommend storing only leave days taken. The other two can easily be calculated when you need the values.

To calculate till present date I got the picture, now my problem is that I want it update itself every month when the adding days per month are added.

Can you please give the example in codes. PLEASE.

Thanx

Please Read This

I'm having to decipher what you are asking, which means I dont understand the question fully. Please explain exactly the scenario so we are clear -- after you read the above link.

What I've meant was that the previous reply to my questions was understood and although I haven't test I got the picture. Now what I'm asking is that after I created that code how will I make it to update itself(adding days per month (y)) that will give the exact Leave Days Left of a member, that will be desplayed in the field that will show the total leave days of the member after all the calculations. Atually how will I loop this problem. If my explanation is not clear, please notify me sothat I try to explain from the start.

Please bear with me as I'm new in using the virtual basics.

Thanx.

I assume you mean you understood my post. OK. Then you understood that

I'd recommend storing only leave days taken. The other two can easily be calculated when you need the values.

means the only value you store in the database is the number of leave days already taken.

So, when you run the report, calculate
1) the number of leave days allowed since hire
2) subtract the number of days taken
3) display what's left as the number of days still available.

And since you have read the link, you also understand why we are not posting code... If not, I'll explain further.

Also:

I'm new with VB ...

By the way, I' new with the VB.

Please bear with me as I'm new in using the virtual basics.

Is there some reason you keep beating us over the head with your newness? It's not that we don't care if you're new. We will help you without you having to remind us all the time... :icon_wink:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.