TranceAddict Forums

TranceAddict Forums (www.tranceaddict.com/forums)
- Chill Out Room
-- Looking for a good Visual Basic programmer


Posted by benfica88 on May-17-2002 00:02:

Looking for a good Visual Basic programmer

I need help with a visual basic problem. I have to create a program in where you input two dates: month,day, year format.
And the program is to figure out wether the dates are in order and proper and to calculate the days in between. This is what i have so far but im stumped...

Private Sub cmdMonths_Click()

Y1 = Val(TxtYearone.Text)
Y2 = Val(TxtYeartwo.Text)
M1 = Val(TxtMonthone.Text)
M2 = Val(TxtMonthtwo.Text)
days = Val(TxtDayone.Text)
Days2 = Val(TxtDaytwo.Text)

'Check months and days
Select Case M1
Case 1, 3, 5, 7, 8, 10, 12
If days > 31 Or days < 1 Then
picBox.Print , "Bad day 1"
End If
Case 4, 6, 9, 11
If days > 30 Or days < 1 Then
picBox.Print , "Bad Day 2"
End If
Case 2
If (Y1 Mod 4) = 0 Then
days = 29
Else
days = 28
End If
Case Else
picBox.Print , "Bad month 1"
End Select

Select Case M2
Case 1, 3, 5, 7, 8, 10, 12
If Days2 > 31 Or Days2 < 1 Then
picBox.Print , "Bad day 3 "
End If
Case 4, 6, 9, 11
If Days2 > 30 Or Days2 < 1 Then
picBox.Print , "Bad day 4 "
End If
Case 2
If (Y2 Mod 4) = 0 Then
days = 29
Else
days = 28
End If
Case Else
picBox.Print , "Bad month 2"
End Select

'Check Years
If Y1 < 2000 Or Y1 > 2002 Then
picBox.Print , "Bad Year 1"
End If
If Y2 < 2000 Or Y2 > 2002 Then
picBox.Print , "Bad Year 2"
End If

'Check Julian dates
Dim FOM(12)
FOM(1) = 1
FOM(2) = 32
FOM(3) = 60
FOM(4) = 91
FOM(5) = 121
FOM(6) = 152
FOM(7) = 182
FOM(8) = 213
FOM(9) = 244
FOM(10) = 274
FOM(11) = 305
FOM(12) = 335

Jul = (FOM(M1) + D1) - 1
Jul2 = (FOM(M2) + D2) - 1

If Y1 - Y2 Then
picBox.Print (Jul2 - Jul)
End If






For I = 1 To 12 Step 1
If M1 > 12 Then
Jul = 0
Else
Jul = (FOM(M1) + days) - 1
End If
Next I



End Sub

THe dates also have to be between 2000-2002 wich makes it a lot harder. The program has to be dimmed as is above and set in Julian dates. I got the program to check the dates for validity
but can't come up with a statement to do the math for the days in between.I know it has to be something like this:
I know it's something like this:
Jul = (FOM(M1) + D1) - 1
Jul2 = (FOM(M2) + D2) - 1

Any help very much appreciated...


Posted by JohnSmith on May-17-2002 16:51:

uh.. you don't have to code that yourself man.

there is a date diff function for that:
http://www.w3schools.com/vbscript/func_datediff.asp

just check the dates for validity first, then send them into the datediff() function, and you are good to go.

unless, this is a school assignment and you HAVE to do it the hard way or something..

in which case, your on your own!

cheers m8.


Posted by benfica88 on May-17-2002 16:54:

yep, school assignment



Powered by: vBulletin
Copyright © 2000-2021, Jelsoft Enterprises Ltd.