MedVision ad

VB6.0 help ... Counting fortnights + Monthly interest charge (1 Viewer)

Ghost1788

Member
Joined
Jan 30, 2005
Messages
276
Location
Sydney
Gender
Male
HSC
2005
Does anyone know how to code a monthview control to produce the following values
("The "*" represents the monthly anniversary of the settlement date which in this case is the 19th,")
12/04/2005
* 19/04/2005
26/04/2005
10/05/2005
* 19/05/2005
24/05/2005
7/06/2005
* 19/06/2005
21/06/2005
5/07/2005
* 19/07/2005
2/08/2005
16/08/2005
* 19/08/2005
30/08/2005
13/09/2005
* 19/09/2005
27/09/2005
11/10/2005
* 19/10/2005
25/10/2005
8/11/2005
* 19/11/2005
22/11/2005
6/12/2005
* 19/12/2005
20/12/2005
3/01/2006
17/01/2006
* 19/01/2006
31/01/2006
14/02/2006
* 19/02/2006
28/02/2006
14/03/2006
* 19/03/2006
28/03/2006
11/04/2006
* 19/04/2006
25/04/2006
9/05/2006
* 19/05/2006
23/05/2006
6/06/2006
* 19/06/2006
20/06/2006
4/07/2006
18/07/2006
* 19/07/2006
1/08/2006
15/08/2006
* 19/08/2006
29/08/2006
12/09/2006
* 19/09/2006
26/09/2006
10/10/2006
* 19/10/2006
24/10/2006
7/11/2006
* 19/11/2006
21/11/2006
5/12/2006
* 19/12/2006
2/01/2007
16/01/2007
* 19/01/2007
30/01/2007
13/02/2007
* 19/02/2007
27/02/2007
13/03/2007
* 19/03/2007
27/03/2007
10/04/2007
* 19/04/2007
24/04/2007
8/05/2007
* 19/05/2007
22/05/2007
5/06/2007
* 19/06/2007
3/07/2007
17/07/2007
* 19/07/2007
31/07/2007
14/08/2007
* 19/08/2007
28/08/2007
11/09/2007
* 19/09/2007
25/09/2007
9/10/2007
* 19/10/2007
23/10/2007
6/11/2007
* 19/11/2007
20/11/2007
4/12/2007
18/12/2007
* 19/12/2007
1/01/2008
15/01/2008
* 19/01/2008
29/01/2008
12/02/2008
* 19/02/2008
26/02/2008
11/03/2008
* 19/03/2008
25/03/2008
8/04/2008
* 19/04/2008


It is adding 14 days(a fortnight) to the date but for each month it must show the 19th of that month and it must produce the result just like above(in chronological order)
so does anyone have any ideas
This is for my major work(a mortgage tracker), i have tried writing the code 5 times each time sepeately with out any luck plz help me out if u can...
 

steeve

SteeVe
Joined
Sep 10, 2004
Messages
12
Gender
Male
HSC
2005
What do u wanna output the values to?

eg if i were to output the values to a text box (text1.text)

Private Sub OutputDates(StartDate As Variant, DateCount, SettleDay)
'StartDate in the form of DDMMYYYY
CurrentDay = Int(Left$(StartDate, 2))
Currentmonth = Int(Mid$(StartDate, 3, 2))
CurrentYear = Int(Right$(StartDate, 4))

SettleDay = Int(SettleDay)
Counter = 0
Do Until Counter = DateCount
If Int(CurrentDay + 14) > SettleDay And Int(CurrentDay) < SettleDay Then
Text1.Text = Text1.Text & "* " & SettleDay & "/" & Currentmonth & "/" & CurrentYear & vbCrLf
End If
Select Case Currentmonth
Case 1, 3, 5, 7, 8, 10, 12
CurrentDay = CurrentDay + 14
If Int(CurrentDay) > 31 Then
Currentmonth = Currentmonth + 1
If Int(Currentmonth) > 12 Then
CurrentYear = CurrentYear + 1
Currentmonth = 1
End If
CurrentDay = CurrentDay - 31
If Int(CurrentDay) > Int(SettleDay) Then
CurrentDay = SettleDay
End If
End If

Case 4, 6, 9, 11
CurrentDay = CurrentDay + 14
If Int(CurrentDay) > 30 Then
Currentmonth = Currentmonth + 1
If Int(Currentmonth) > 12 Then
CurrentYear = CurrentYear + 1
Currentmonth = 1
End If
CurrentDay = CurrentDay - 30
If Int(CurrentDay) > Int(SettleDay) Then
CurrentDay = SettleDay
End If
End If

Case 2
CurrentDay = CurrentDay + 14
If Int(CurrentDay) > 29 Then
Currentmonth = Currentmonth + 1
If Int(Currentmonth) > 12 Then
CurrentYear = CurrentYear + 1
Currentmonth = 1
End If
CurrentDay = CurrentDay - 29
If Int(CurrentDay) > Int(SettleDay) Then
CurrentDay = SettleDay
End If
End If

End Select
If CurrentDay = SettleDay Then
Text1.Text = Text1.Text & "* " & SettleDay & "/" & Currentmonth & "/" & CurrentYear & vbCrLf
Else
Text1.Text = Text1.Text & CurrentDay & "/" & Currentmonth & "/" & CurrentYear & vbCrLf
End If
Counter = Counter + 1
Loop

End Sub

Go paste it into ur form (not module) and the add a cmd box
and in taht cmd box put

Call OutputDates("12042005", 0, 19)

or what eva date or settle day u require

Try that and see if it works

I get that for my output values which seem to match urs but however do note my code does not account for leap years as i dun know how to tell if its a leap year. looking back at code that i have done b4 its something like

If (CurrentYear Mod 4 = 0) Then

* 19/4/2005
26/4/2005
10/5/2005
* 19/5/2005
24/5/2005
7/6/2005
* 19/6/2005
21/6/2005
5/7/2005
* 19/7/2005
2/8/2005
16/8/2005
* 19/8/2005
30/8/2005
13/9/2005
* 19/9/2005
27/9/2005
11/10/2005
* 19/10/2005
25/10/2005
8/11/2005
* 19/11/2005
22/11/2005
6/12/2005
* 19/12/2005
 

steeve

SteeVe
Joined
Sep 10, 2004
Messages
12
Gender
Male
HSC
2005
I did a bit more testing on it and ive found some more bugs which u can prob work on caus i am too lazy and wanan play DOTA =).

1. if u enter 31 or 30 as settle date it ignores the fact that some months cant have 31 or 30 days or even 29 for that matter

2. u need to have some kinda data validation for the StartDate, DateCount, SettleDay as they dun work with letters and some integers such as 0

i made the thing into a little vb thing so u can see it working urself

its easier to read too with the indenting all dere

http://keiith.l2p.net/steve/vbthing.zip
 

Ghost1788

Member
Joined
Jan 30, 2005
Messages
276
Location
Sydney
Gender
Male
HSC
2005
Thanks its not exactly what i had in mind i was thinking based on monthview control, and export to excel.

I think i worked out how to do just afta i started the thread. i in the process of checking whether my code is bug proof.

But thanks u showed me a different approach to the problem..

EDIT: Hey afta working with my code i found it was wrong and your logic prevails :confused: so i have decided to use ur code, so how do i acknowledge ur work in my biography
 
Last edited:

Ghost1788

Member
Joined
Jan 30, 2005
Messages
276
Location
Sydney
Gender
Male
HSC
2005
ALso do u know how to export the dates to excel such that say all dates are shown in say column a while all dates of the settlement are shown in col B note that each date has its 'OWN' row...
 

Ghost1788

Member
Joined
Jan 30, 2005
Messages
276
Location
Sydney
Gender
Male
HSC
2005
ok srry i didnt update but i found that out now but umm do u or anyone else on Bos know any good sites to learn Excel late binding technique.

The program i making needs to be backward compatible with different versions of excel, unfortunately i only found this out today and i running office 2003, so i need to learn it double fast since my program is based on early binding(the easier method)
 

steeve

SteeVe
Joined
Sep 10, 2004
Messages
12
Gender
Male
HSC
2005
soz mate i got no idear ><. Are u attempting to read from a excel file or write to one?

Also by the looks of things ur making ur program too comlicated like what i did.
When i handed in my major a few weeks ago it scored great. I did about 120 pages of documentation and the program functionality was great. However others that did 20 pages of documentation and had a crappy little program scored just a little worse than me.

All programs are criteria marked, no point making something tahts worth more than 100%
 

Ghost1788

Member
Joined
Jan 30, 2005
Messages
276
Location
Sydney
Gender
Male
HSC
2005
both read and write...
i wanted to do sumthing different and the only thing i could think of is a mortgage tracker...i very unimmaginative.....anyway...its a bit late to change and i thought that it would help me understand how a mortgage works...(trying to hit two birds with one stone...)
 

steeve

SteeVe
Joined
Sep 10, 2004
Messages
12
Gender
Male
HSC
2005
i rkn instead of making it all fancy u should make ur program do graphs and stuff and make it look good and have lots of easy to do functions rather than to make something thats got 1 big impressive function but lacking in little things that equaly impress.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top