programmershelp source code examples for asp, php, perl, delphi, c, c++, visual basic, java and others
programmershelp source code examples for asp, php, perl, delphi, c, c++, visual basic, java and others
programmershelp source code examples for asp, php, perl, delphi, c, c++, visual basic, java and others
   Main Menu
programmershelp source code examples for asp, php, perl, delphi, c, c++, visual basic, java and others

HOME

.Net
ASP
Assembly
C
C++
Delphi
HTML
Java
JavaScript Site
MySQL
PC interface
Powershell
Perl
PHP
VBScript
Visual Basic
XML

US Job listings




   Misc
programmershelp source code examples for asp, php, perl, delphi, c, c++, visual basic, java and others

   Amazon
programmershelp source code examples for asp, php, perl, delphi, c, c++, visual basic, java and others

   Links
programmershelp source code examples for asp, php, perl, delphi, c, c++, visual basic, java and others

programmershelp source code examples for asp, php, perl, delphi, c, c++, visual basic, java and others
Code examples are sponsored by Webmastersearn : make money with your website

 

Standard Code Module for Calendar Functions

Standard Code Module for Calendar Functions

'********************************************************************
'Standard Code Module for Calendar Functions
'Programmers Name: Steve Carpenter
'E-Mail: lanztek@hotmail.com
'File Name: Calendar_Functions.bas
'Date created: February 10, 2002
'Last Modified: February 15, 2002
'Function Names: GetDayOfWeek()
' IsLeapYear()
' DaysInMonth()
'
'This Module contains functions to;
' 1.)Find what day of the week a particular day is
' 2.)Determine if it is leap year or not
' 3.)Determine the number of days in a month (even in a leap year)
'
'In each of the functions in this module type for year will allways be LONG
'type for month and day will be of INTEGER type
'*********************************************************************
'
'
'
'
'*********************************************************************
Public Function GetDayOfWeek(MyYear as Long, MyMonth as Integer, MyDay as Integer) as Integer
'************************************************************
'GetDayOfWeek() Function used to find what day of the week a certain date is
'The algorhythm for finding the day is basically borrowed from the Linux CAL command
'source code with some modifications for Visual Basic
'This function is passed 2 variables of Integer type and 1 of long type
'Year, Month, Day
'This function returns 1 variable "GetDayOfWeek" of Integer type
'all division in this function are of INTEGER type
'this function will return an integer value of 0 to 6
'0 is sunday, 1 is monday, 2 is tuesday...
'this function does handle leap year
'************************************************************

Dim Var1 as Integer

'var1 will allways be 0 or 1
Var1 = Int((14 - MyMonth) / 12)

'subtract either 0 or 1 from the year
MyYear = MyYear - Var1

'remember order of operations if you are doing this by hand
MyMonth = MyMonth + 12 * Var1 - 2

'if you wanted to find the first day of the month, you would make
'MyDay = 1 in the calling procedure.

GetDayOfWeek = (MyDay + MyYear + Int(MyYear / 4) - Int(MyYear / 100) + _
Int(MyYear / 400) + Int((31 * MyMonth) / 12)) Mod 7

'getdayofweek will now contain the value of 0 to 6

End Function
'********************************************************************
'
'
'
'
'
'********************************************************************
Public Function IsLeapYear(MyYear as Long) as Boolean

'************************************************************
'IsLeapYear() Function used to find if a particular year is leap year
'or not. This function is passed 1 long variable
'returns IsLeapYear--a boolean
'************************************************************

IsLeapYear = MyYear Mod 4 = 0 And (MyYear Mod 100 <> 0 Or MyYear Mod 400 = 0)

End Function
'********************************************************************
'
'
'
'
'********************************************************************
Public Function GetDaysInMonth(MyMonth as Integer, MyYear as Long) as Integer
'************************************************************
'GetDaysInMonth() function used to find how many days are in
' a particular month
'this function receives 2 integer variable Month and
'Year and returns the numbers of days in the month "DaysInMonth"
'if the intMonth = 2, which is February, then it uses the
'IsLeapYear() function to find out if it is leap year
'If it is leap year, February will have 29 days
'************************************************************

Select Case intMonth
Case 2
If IsLeapYear(MyYear) then
GetDaysInMonth = 29
Else
GetDaysInMonth = 28
Case 4,6,9,11
GetDaysInMonth = 30
Case 1, 3, 5, 7, 8, 10, 12
GetDaysInMonth = 31
End Select
End Function
'********************************************************************


Clickbank mall, make money
sell software, make money
Hosted magazine site : make money with no website



 


 




   Sponsors
 

   Software
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals

   Source Code
displays a list of My Computer locations(VBScript)
select box example(HTML)
get the host name(ASP.net)
View source code(VB)
Name of Browser(Javascript)
save text to a file(VB)
display information about a file(VB)
random lines(VB)




Copyright © 2004 by programmershelp.co.uk