473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

how to calculate the number of days in a month using vb6.0

chandru8
145 100+
hi to all
if the current month is jan,i need to calculate the number of days of feb
is it possible without assigning number of days manually to a variable
Feb 23 '08 #1
4 15598
VACEPROGRAMER
168 100+
Of courese you can, but can you explain me what you going to do whit sample words . .. . Please

VxE
Feb 23 '08 #2
creative1
274 100+
To calculate # of days in current month

Expand|Select|Wrap|Line Numbers
  1. MsgBox DateAdd("m", 1, Now) - Now
For any other month

Expand|Select|Wrap|Line Numbers
  1. Dim Date1 As Date
  2. Date1 = "01/03/2006"                ' for month of March
  3. MsgBox DateAdd("m", 1, Date1) - Date1
It might help a little bit

Regards
Feb 23 '08 #3
Killer42
8,435 Expert 8TB
Just for fun, here's another alternative. (There's almost always more than one way to accomplish things, in programming).

Expand|Select|Wrap|Line Numbers
  1. Public Function DaysInMonth(ByVal Yr As Long, ByVal Mnth As Long) As Long
  2.   ' Return the number of days in the specified month.
  3.   DaysInMonth = Day(DateSerial(Yr, Mnth + 1, 1) - 1)
  4. End Function
Of course, given that it's a single calculation, there may not be much point putting it in a function. Also, note that I just use Long data type wherever possible, for efficiency purposes. What you use is up to you. :)
Feb 25 '08 #4
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdGo_Click()
  2. Dim month_number As Integer
  3. Dim year_number As Integer
  4.  
  5.     month_number = Month(txtMonth.Text)
  6.     year_number = Year(txtMonth.Text)
  7.     MsgBox "Days: " & Format$(Day(DateSerial(year_number, _
  8.         month_number + 1, 0)))
  9. End Sub
Chetan Nagar
Mar 14 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

26
by: Frank | last post by:
For my website i would like to display the age of my son in years, months, days and hours. For now i manage to get a result for totals. Like the total number of days. This is the beginning: ...
7
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using...
6
by: charliewest | last post by:
Can someone pls point me to or recommend the easiest way to calculate someone´s age using the TimeSpan object, in .NET CF? Isn´t there a simple way to use the TimeSpan object to calculate the...
8
by: amackeyb | last post by:
I need to do a program that calculate the days from a date whatever since 20XX to January 1st. 2000. How can I do that?? I have this, is it correct??? # include <iostream.h> # include...
3
ChaseCox
by: ChaseCox | last post by:
Hi all, I have a problem that I have been looking at for a couple days now and I can not quite get it to work. I would like to calculate the cumulative percent failure of a certain product in...
5
by: Beemer Biker | last post by:
I cant seem to get that date into any DateTime to make my calculation directly by subtracting "01-01-0000" from "now". After reading this:...
5
by: Mike | last post by:
I use c#, V2005 How I can get difference between two dates and get value in month(s) I had found some solutions but it is not exactly what I need. private static int...
15
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but...
5
FishVal
by: FishVal | last post by:
IMHO, the following is not a how-to-do instruction to solve a particular problem but more a concept-proof stuff demonstrating possibilities of SQL. So, let us say the problem is to calculate...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.