1 |
// ***** BEGIN LICENSE BLOCK *****
|
2 |
// * Version: MPL 1.1
|
3 |
// *
|
4 |
// * The contents of this file are subject to the Mozilla Public License Version
|
5 |
// * 1.1 (the "License"); you may not use this file except in compliance with
|
6 |
// * the License. You may obtain a copy of the License at
|
7 |
// * http://www.mozilla.org/MPL/
|
8 |
// *
|
9 |
// * Software distributed under the License is distributed on an "AS IS" basis,
|
10 |
// * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
11 |
// * for the specific language governing rights and limitations under the
|
12 |
// * License.
|
13 |
// *
|
14 |
// * The Original Code is TurboPower SysTools
|
15 |
// *
|
16 |
// * The Initial Developer of the Original Code is
|
17 |
// * TurboPower Software
|
18 |
// *
|
19 |
// * Portions created by the Initial Developer are Copyright (C) 1996-2002
|
20 |
// * the Initial Developer. All Rights Reserved.
|
21 |
// *
|
22 |
// * Contributor(s):
|
23 |
// *
|
24 |
// * ***** END LICENSE BLOCK *****
|
25 |
//---------------------------------------------------------------------------
|
26 |
#include <vcl\vcl.h>
|
27 |
#pragma hdrstop
|
28 |
|
29 |
#include "FinCalu.h"
|
30 |
//---------------------------------------------------------------------------
|
31 |
#pragma link "Grids"
|
32 |
#pragma link "StFin"
|
33 |
#pragma link "StDate"
|
34 |
#pragma link "StDateSt"
|
35 |
#pragma resource "*.dfm"
|
36 |
TFinCalForm *FinCalForm;
|
37 |
//---------------------------------------------------------------------------
|
38 |
__fastcall TFinCalForm::TFinCalForm(TComponent* Owner)
|
39 |
: TForm(Owner)
|
40 |
{
|
41 |
}
|
42 |
//---------------------------------------------------------------------------
|
43 |
void __fastcall TFinCalForm::FT(TWinControl* F, short T, String S)
|
44 |
{
|
45 |
TEdit* edit;
|
46 |
edit = (TEdit*) F;
|
47 |
edit->Enabled = true;
|
48 |
edit->Color = clYellow;
|
49 |
edit->TabOrder = T;
|
50 |
edit->Hint = S;
|
51 |
edit->ShowHint = true;
|
52 |
}
|
53 |
//---------------------------------------------------------------------------
|
54 |
void __fastcall TFinCalForm::SetupAccruedInterestPeriodic()
|
55 |
{
|
56 |
FT(D1Edit, 1, "Issue");
|
57 |
FT(D2Edit, 2, "Settlement");
|
58 |
FT(D3Edit, 3, "Maturity");
|
59 |
FT(E1Edit, 4, "Rate");
|
60 |
FT(E2Edit, 5, "Par");
|
61 |
FT(FreqEdit, 6, "Frequency");
|
62 |
FT(BasEdit, 7, "Basis");
|
63 |
}
|
64 |
//---------------------------------------------------------------------------
|
65 |
void __fastcall TFinCalForm::SetupAccruedInterestMaturity()
|
66 |
{
|
67 |
FT(D1Edit, 1, "Issue");
|
68 |
FT(D2Edit, 2, "Maturity");
|
69 |
FT(E1Edit, 3, "Rate");
|
70 |
FT(E2Edit, 4, "Par");
|
71 |
FT(BasEdit, 5, "Basis");
|
72 |
}
|
73 |
//---------------------------------------------------------------------------
|
74 |
void __fastcall TFinCalForm::SetupCumulativeInterest()
|
75 |
{
|
76 |
FT(E1Edit, 1, "Rate");
|
77 |
FT(I1Edit, 2, "NPeriods");
|
78 |
FT(E2Edit, 3, "Present Value");
|
79 |
FT(I2Edit, 4, "Start Period");
|
80 |
FT(I3Edit, 5, "End Period");
|
81 |
FT(FreqEdit, 6, "Frequency");
|
82 |
FT(TimEdit, 7, "Timing");
|
83 |
}
|
84 |
//---------------------------------------------------------------------------
|
85 |
void __fastcall TFinCalForm::SetupCumulativePrincipal()
|
86 |
{
|
87 |
SetupCumulativeInterest();
|
88 |
}
|
89 |
//---------------------------------------------------------------------------
|
90 |
void __fastcall TFinCalForm::SetupDiscountRate()
|
91 |
{
|
92 |
FT(D1Edit, 1, "Settlement");
|
93 |
FT(D2Edit, 2, "Maturity");
|
94 |
FT(E1Edit, 3, "Price");
|
95 |
FT(E2Edit, 4, "Redemption");
|
96 |
FT(BasEdit, 5, "Basis");
|
97 |
}
|
98 |
//---------------------------------------------------------------------------
|
99 |
void __fastcall TFinCalForm::SetupEffectiveInterestRate()
|
100 |
{
|
101 |
FT(E1Edit, 1, "Nominal Rate");
|
102 |
FT(FreqEdit, 2, "Frequency");
|
103 |
}
|
104 |
//---------------------------------------------------------------------------
|
105 |
void __fastcall TFinCalForm::SetupNominalInterestRate()
|
106 |
{
|
107 |
FT(E1Edit, 1, "Effective Rate");
|
108 |
FT(FreqEdit, 2, "Frequency");
|
109 |
}
|
110 |
//---------------------------------------------------------------------------
|
111 |
void __fastcall TFinCalForm::SetupInterestRate()
|
112 |
{
|
113 |
FT(I1Edit, 1, "NPeriods");
|
114 |
FT(E1Edit, 2, "Payment");
|
115 |
FT(E2Edit, 3, "Present Value");
|
116 |
FT(E3Edit, 4, "Future Value");
|
117 |
FT(FreqEdit, 5, "Frequency");
|
118 |
FT(TimEdit, 6, "Timing");
|
119 |
FT(E4Edit, 7, "Guess");
|
120 |
}
|
121 |
//---------------------------------------------------------------------------
|
122 |
void __fastcall TFinCalForm::SetupReceivedAtMaturity()
|
123 |
{
|
124 |
FT(D1Edit, 1, "Settlement");
|
125 |
FT(D2Edit, 2, "Maturity");
|
126 |
FT(E1Edit, 3, "Investment");
|
127 |
FT(E2Edit, 4, "Discount");
|
128 |
FT(BasEdit, 5, "Basis");
|
129 |
}
|
130 |
//---------------------------------------------------------------------------
|
131 |
void __fastcall TFinCalForm::SetupYieldPeriodic()
|
132 |
{
|
133 |
FT(D1Edit, 1, "Settlement");
|
134 |
FT(D2Edit, 2, "Maturity");
|
135 |
FT(E1Edit, 3, "Rate");
|
136 |
FT(E2Edit, 4, "Price");
|
137 |
FT(E3Edit, 5, "Redemption");
|
138 |
FT(FreqEdit, 6, "Frequency");
|
139 |
FT(BasEdit, 7, "Basis");
|
140 |
}
|
141 |
//---------------------------------------------------------------------------
|
142 |
void __fastcall TFinCalForm::SetupYieldDiscounted()
|
143 |
{
|
144 |
FT(D1Edit, 1, "Settlement");
|
145 |
FT(D2Edit, 2, "Maturity");
|
146 |
FT(E1Edit, 3, "Price");
|
147 |
FT(E2Edit, 4, "Redemption");
|
148 |
FT(BasEdit, 5, "Basis");
|
149 |
}
|
150 |
//---------------------------------------------------------------------------
|
151 |
void __fastcall TFinCalForm::SetupYieldMaturity()
|
152 |
{
|
153 |
FT(D1Edit, 1, "Issue");
|
154 |
FT(D2Edit, 2, "Settlement");
|
155 |
FT(D3Edit, 3, "Maturity");
|
156 |
FT(E1Edit, 4, "Rate");
|
157 |
FT(E2Edit, 5, "Price");
|
158 |
FT(BasEdit, 6, "Basis");
|
159 |
}
|
160 |
//---------------------------------------------------------------------------
|
161 |
void __fastcall TFinCalForm::SetupTBillEquivYield()
|
162 |
{
|
163 |
FT(D1Edit, 1, "Settlement");
|
164 |
FT(D2Edit, 2, "Maturity");
|
165 |
FT(E1Edit, 3, "Discount");
|
166 |
}
|
167 |
//---------------------------------------------------------------------------
|
168 |
void __fastcall TFinCalForm::SetupTBillPrice()
|
169 |
{
|
170 |
SetupTBillEquivYield();
|
171 |
}
|
172 |
//---------------------------------------------------------------------------
|
173 |
void __fastcall TFinCalForm::SetupTBillYield()
|
174 |
{
|
175 |
FT(D1Edit, 1, "Settlement");
|
176 |
FT(D2Edit, 2, "Maturity");
|
177 |
FT(E1Edit, 3, "Price");
|
178 |
}
|
179 |
//---------------------------------------------------------------------------
|
180 |
void __fastcall TFinCalForm::SetupBondDuration()
|
181 |
{
|
182 |
FT(D1Edit, 1, "Settlement");
|
183 |
FT(D2Edit, 2, "Maturity");
|
184 |
FT(E1Edit, 3, "Rate");
|
185 |
FT(E2Edit, 4, "Yield");
|
186 |
FT(FreqEdit, 5, "Frequency");
|
187 |
FT(BasEdit, 6, "Basis");
|
188 |
}
|
189 |
//---------------------------------------------------------------------------
|
190 |
void __fastcall TFinCalForm::SetupModifiedDuration()
|
191 |
{
|
192 |
SetupBondDuration();
|
193 |
}
|
194 |
//---------------------------------------------------------------------------
|
195 |
void __fastcall TFinCalForm::SetupFutureValueSchedule()
|
196 |
{
|
197 |
FT(E1Edit, 1, "Principal");
|
198 |
FT(VAEdit, 2, "Schedule");
|
199 |
FT(I1Edit, 3, "NRates");
|
200 |
}
|
201 |
//---------------------------------------------------------------------------
|
202 |
void __fastcall TFinCalForm::SetupModifiedIRR()
|
203 |
{
|
204 |
FT(VAEdit, 1, "Values");
|
205 |
FT(I1Edit, 2, "NValues");
|
206 |
FT(E1Edit, 3, "Finance Rate");
|
207 |
FT(E2Edit, 4, "Reinvest Rate");
|
208 |
}
|
209 |
//---------------------------------------------------------------------------
|
210 |
void __fastcall TFinCalForm::SetupNonperiodicIRR()
|
211 |
{
|
212 |
FT(I1Edit, 1, "NValues");
|
213 |
FT(VAEdit, 2, "Values");
|
214 |
FT(DAEdit, 3, "Dates");
|
215 |
FT(E1Edit, 4, "Guess");
|
216 |
}
|
217 |
//---------------------------------------------------------------------------
|
218 |
void __fastcall TFinCalForm::SetupNonperiodicNPV()
|
219 |
{
|
220 |
FT(I1Edit, 1, "NValues");
|
221 |
FT(E1Edit, 2, "Rate");
|
222 |
FT(VAEdit, 3, "Values");
|
223 |
FT(DAEdit, 4, "Dates");
|
224 |
}
|
225 |
//---------------------------------------------------------------------------
|
226 |
void __fastcall TFinCalForm::SetupDecliningBalance()
|
227 |
{
|
228 |
FT(E1Edit, 1, "Cost");
|
229 |
FT(E2Edit, 2, "Salvage");
|
230 |
FT(I1Edit, 3, "Life");
|
231 |
FT(I2Edit, 4, "Period");
|
232 |
FT(I3Edit, 5, "Month");
|
233 |
}
|
234 |
//---------------------------------------------------------------------------
|
235 |
void __fastcall TFinCalForm::SetupVariableDecliningBalance()
|
236 |
{
|
237 |
FT(E1Edit, 1, "Cost");
|
238 |
FT(E2Edit, 2, "Salvage");
|
239 |
FT(I1Edit, 3, "Life");
|
240 |
FT(E3Edit, 4, "Start");
|
241 |
FT(E4Edit, 5, "End");
|
242 |
FT(E5Edit, 6, "Factor");
|
243 |
FT(BoolEdit, 7, "No Switch");
|
244 |
}
|
245 |
//---------------------------------------------------------------------------
|
246 |
void __fastcall TFinCalForm::SetupDollarToDecimal()
|
247 |
{
|
248 |
FT(E1Edit, 1, "Fractional Dollar");
|
249 |
FT(I1Edit, 2, "Fraction");
|
250 |
}
|
251 |
//---------------------------------------------------------------------------
|
252 |
void __fastcall TFinCalForm::SetupDollarToFraction()
|
253 |
{
|
254 |
FT(E1Edit, 1, "Decimal Dollar");
|
255 |
FT(I1Edit, 2, "Fraction");
|
256 |
}
|
257 |
//---------------------------------------------------------------------------
|
258 |
void __fastcall TFinCalForm::SetupDollarToDecimalText()
|
259 |
{
|
260 |
FT(E1Edit, 1, "Decimal Dollar");
|
261 |
}
|
262 |
//---------------------------------------------------------------------------
|
263 |
void __fastcall TFinCalForm::SetupDollarToFractionStr()
|
264 |
{
|
265 |
FT(E1Edit, 1, "Fractional Dollar");
|
266 |
FT(I1Edit, 2, "Fraction");
|
267 |
}
|
268 |
//---------------------------------------------------------------------------
|
269 |
void __fastcall TFinCalForm::SetupRoundToDecimal()
|
270 |
{
|
271 |
FT(E1Edit, 1, "Value");
|
272 |
FT(I1Edit, 2, "Places");
|
273 |
FT(BoolEdit, 3, "Bankers");
|
274 |
}
|
275 |
//---------------------------------------------------------------------------
|
276 |
void __fastcall TFinCalForm::SetupIsCardValid()
|
277 |
{
|
278 |
FT(StrEdit, 1, "Card Number");
|
279 |
}
|
280 |
//---------------------------------------------------------------------------
|
281 |
void __fastcall TFinCalForm::SetupNetPresentValue()
|
282 |
{
|
283 |
FT(E1Edit, 1, "Rate");
|
284 |
FT(I1Edit, 2, "NValues");
|
285 |
FT(VAEdit, 3, "Values");
|
286 |
}
|
287 |
//---------------------------------------------------------------------------
|
288 |
void __fastcall TFinCalForm::SetupFutureValue()
|
289 |
{
|
290 |
FT(E1Edit, 1, "Rate");
|
291 |
FT(I1Edit, 2, "NPeriods");
|
292 |
FT(E2Edit, 3, "Payment");
|
293 |
FT(E3Edit, 4, "Present Value");
|
294 |
FT(FreqEdit, 5, "Frequency");
|
295 |
FT(TimEdit, 6, "Timing");
|
296 |
}
|
297 |
//---------------------------------------------------------------------------
|
298 |
void __fastcall TFinCalForm::SetupPresentValue()
|
299 |
{
|
300 |
FT(E1Edit, 1, "Rate");
|
301 |
FT(I1Edit, 2, "NPeriods");
|
302 |
FT(E2Edit, 3, "Payment");
|
303 |
FT(E3Edit, 4, "Future Value");
|
304 |
FT(FreqEdit, 5, "Frequency");
|
305 |
FT(TimEdit, 6, "Timing");
|
306 |
}
|
307 |
//---------------------------------------------------------------------------
|
308 |
void __fastcall TFinCalForm::SetupBondPrice()
|
309 |
{
|
310 |
FT(D1Edit, 1, "Settlement");
|
311 |
FT(D2Edit, 2, "Maturity");
|
312 |
FT(E1Edit, 3, "Rate");
|
313 |
FT(E2Edit, 4, "Yield");
|
314 |
FT(E3Edit, 5, "Redemption");
|
315 |
FT(FreqEdit, 6, "Frequency");
|
316 |
FT(BasEdit, 7, "Basis");
|
317 |
}
|
318 |
//---------------------------------------------------------------------------
|
319 |
void __fastcall TFinCalForm::SetupPayment()
|
320 |
{
|
321 |
FT(E1Edit, 1, "Rate");
|
322 |
FT(I1Edit, 2, "NPeriods");
|
323 |
FT(E2Edit, 3, "Present Value");
|
324 |
FT(E3Edit, 4, "Future Value");
|
325 |
FT(FreqEdit, 5, "Frequency");
|
326 |
FT(TimEdit, 6, "Timing");
|
327 |
}
|
328 |
//---------------------------------------------------------------------------
|
329 |
void __fastcall TFinCalForm::SetupInternalRateOfReturn()
|
330 |
{
|
331 |
FT(I1Edit, 1, "NValues");
|
332 |
FT(VAEdit, 2, "Values");
|
333 |
FT(E1Edit, 3, "Guess");
|
334 |
}
|
335 |
//---------------------------------------------------------------------------
|
336 |
|
337 |
|
338 |
|
339 |
void __fastcall TFinCalForm::GoBtnClick(TObject *Sender)
|
340 |
{
|
341 |
long double FR = 0;
|
342 |
String SR = "";
|
343 |
switch (Functions->ItemIndex) {
|
344 |
case 0 : FR = AccruedInterestMaturity(DateVar[0], DateVar[1], ExtVar[0],
|
345 |
ExtVar[1], BasVar);
|
346 |
break;
|
347 |
case 1 : FR = AccruedInterestPeriodic(DateVar[0], DateVar[1], DateVar[2],
|
348 |
ExtVar[0], ExtVar[1], FreqVar, BasVar);
|
349 |
break;
|
350 |
case 2 : FR = BondDuration(DateVar[0], DateVar[1], ExtVar[0], ExtVar[1],
|
351 |
FreqVar, BasVar);
|
352 |
break;
|
353 |
case 3 : FR = BondPrice(DateVar[0], DateVar[1], ExtVar[0], ExtVar[1],
|
354 |
ExtVar[2], FreqVar, BasVar);
|
355 |
break;
|
356 |
case 4 : FR = CumulativeInterest(ExtVar[0], IntVar[0], ExtVar[1], IntVar[1],
|
357 |
IntVar[2], FreqVar, TimVar);
|
358 |
break;
|
359 |
case 5 : FR = CumulativePrincipal(ExtVar[0], IntVar[0], ExtVar[1], IntVar[1],
|
360 |
IntVar[2], FreqVar, TimVar);
|
361 |
break;
|
362 |
case 6 : FR = DecliningBalance(ExtVar[0], ExtVar[1], IntVar[0], IntVar[1],
|
363 |
IntVar[2]);
|
364 |
break;
|
365 |
case 7 : FR = DiscountRate(DateVar[0], DateVar[1], ExtVar[0], ExtVar[1],
|
366 |
BasVar);
|
367 |
break;
|
368 |
case 8 : FR = DollarToDecimal(ExtVar[0], IntVar[0]);
|
369 |
|
370 |
break;
|
371 |
case 9 : SR = DollarToDecimalText(ExtVar[0]);
|
372 |
|
373 |
break;
|
374 |
case 10 : FR = DollarToFraction(ExtVar[0], IntVar[0]);
|
375 |
|
376 |
break;
|
377 |
case 11 : SR = DollarToFractionStr(ExtVar[0], IntVar[0]);
|
378 |
|
379 |
break;
|
380 |
case 12 : FR = EffectiveInterestRate(ExtVar[0], FreqVar);
|
381 |
|
382 |
break;
|
383 |
case 13 : FR = FutureValue(ExtVar[0], IntVar[0], ExtVar[1], ExtVar[2],
|
384 |
FreqVar, TimVar);
|
385 |
break;
|
386 |
case 14 : FR = FutureValueSchedule16(ExtVar[0], ValArray, IntVar[0]);
|
387 |
|
388 |
break;
|
389 |
case 15 : FR = InterestRate(IntVar[0], ExtVar[0], ExtVar[1], ExtVar[2],
|
390 |
FreqVar, TimVar, ExtVar[3]);
|
391 |
break;
|
392 |
case 16 : FR = InternalRateOfReturn16(ValArray, IntVar[0], ExtVar[0]);
|
393 |
|
394 |
break;
|
395 |
case 17 : if (IsCardValid(StrVar))
|
396 |
SR = "Valid card number";
|
397 |
else
|
398 |
SR = "Invalid card number";
|
399 |
break;
|
400 |
case 18 : FR = ModifiedDuration(DateVar[0], DateVar[1], ExtVar[2],
|
401 |
ExtVar[1], FreqVar, BasVar);
|
402 |
break;
|
403 |
case 19 : FR = ModifiedIRR16(ValArray, IntVar[0], ExtVar[0], ExtVar[1]);
|
404 |
|
405 |
break;
|
406 |
case 20 : FR = NetPresentValue16(ExtVar[0], ValArray, IntVar[0]);
|
407 |
|
408 |
break;
|
409 |
case 21 : FR = NominalInterestRate(ExtVar[0], FreqVar);
|
410 |
|
411 |
break;
|
412 |
case 22 : FR = NonperiodicIRR16(ValArray, DateArray, IntVar[0], ExtVar[0]);
|
413 |
|
414 |
break;
|
415 |
case 23 : FR = NonperiodicNPV16(ExtVar[0], ValArray, DateArray, IntVar[0]);
|
416 |
|
417 |
break;
|
418 |
case 24 : FR = Payment(ExtVar[0], IntVar[0], ExtVar[1], ExtVar[2],
|
419 |
FreqVar, TimVar);
|
420 |
break;
|
421 |
case 25 : FR = PresentValue(ExtVar[0], IntVar[0], ExtVar[1], ExtVar[2],
|
422 |
FreqVar, TimVar);
|
423 |
break;
|
424 |
case 26 : FR = ReceivedAtMaturity(DateVar[0], DateVar[1], ExtVar[0],
|
425 |
ExtVar[1], BasVar);
|
426 |
break;
|
427 |
case 27 : FR = RoundToDecimal(ExtVar[0], IntVar[0], BoolVar);
|
428 |
|
429 |
break;
|
430 |
case 28 : FR = TBillEquivYield(DateVar[0], DateVar[1], ExtVar[0]);
|
431 |
|
432 |
break;
|
433 |
case 29 : FR = TBillPrice(DateVar[0], DateVar[1], ExtVar[0]);
|
434 |
|
435 |
break;
|
436 |
case 30 : FR = TBillYield(DateVar[0], DateVar[1], ExtVar[0]);
|
437 |
|
438 |
break;
|
439 |
case 31 : FR = VariableDecliningBalance(ExtVar[0], ExtVar[1], IntVar[0],
|
440 |
ExtVar[2], ExtVar[3], ExtVar[4], BoolVar);
|
441 |
break;
|
442 |
case 32 : FR = YieldPeriodic(DateVar[0], DateVar[1], ExtVar[0], ExtVar[1],
|
443 |
ExtVar[2], FreqVar, BasVar);
|
444 |
break;
|
445 |
case 33 : FR = YieldDiscounted(DateVar[0], DateVar[1], ExtVar[0],
|
446 |
ExtVar[1], BasVar);
|
447 |
break;
|
448 |
case 34 : FR = YieldMaturity(DateVar[0], DateVar[1], DateVar[2], ExtVar[0],
|
449 |
ExtVar[1], BasVar);
|
450 |
break;
|
451 |
}
|
452 |
FResult->Text = FloatToStr(FR);
|
453 |
SResult->Text = SR;
|
454 |
}
|
455 |
//---------------------------------------------------------------------------
|
456 |
void __fastcall TFinCalForm::FunctionsClick(TObject *Sender)
|
457 |
{
|
458 |
DisableFields();
|
459 |
switch (Functions->ItemIndex) {
|
460 |
case 0 : SetupAccruedInterestMaturity(); break;
|
461 |
case 1 : SetupAccruedInterestPeriodic(); break;
|
462 |
case 2 : SetupBondDuration(); break;
|
463 |
case 3 : SetupBondPrice(); break;
|
464 |
case 4 : SetupCumulativeInterest(); break;
|
465 |
case 5 : SetupCumulativePrincipal(); break;
|
466 |
case 6 : SetupDecliningBalance(); break;
|
467 |
case 7 : SetupDiscountRate(); break;
|
468 |
case 8 : SetupDollarToDecimal(); break;
|
469 |
case 9 : SetupDollarToDecimalText(); break;
|
470 |
case 10 : SetupDollarToFraction(); break;
|
471 |
case 11 : SetupDollarToFractionStr(); break;
|
472 |
case 12 : SetupEffectiveInterestRate(); break;
|
473 |
case 13 : SetupFutureValue(); break;
|
474 |
case 14 : SetupFutureValueSchedule(); break;
|
475 |
case 15 : SetupInterestRate(); break;
|
476 |
case 16 : SetupInternalRateOfReturn(); break;
|
477 |
case 17 : SetupIsCardValid(); break;
|
478 |
case 18 : SetupModifiedDuration(); break;
|
479 |
case 19 : SetupModifiedIRR(); break;
|
480 |
case 20 : SetupNetPresentValue(); break;
|
481 |
case 21 : SetupNominalInterestRate(); break;
|
482 |
case 22 : SetupNonperiodicIRR(); break;
|
483 |
case 23 : SetupNonperiodicNPV(); break;
|
484 |
case 24 : SetupPayment(); break;
|
485 |
case 25 : SetupPresentValue(); break;
|
486 |
case 26 : SetupReceivedAtMaturity(); break;
|
487 |
case 27 : SetupRoundToDecimal(); break;
|
488 |
case 28 : SetupTBillEquivYield(); break;
|
489 |
case 29 : SetupTBillPrice(); break;
|
490 |
case 30 : SetupTBillYield(); break;
|
491 |
case 31 : SetupVariableDecliningBalance(); break;
|
492 |
case 32 : SetupYieldPeriodic(); break;
|
493 |
case 33 : SetupYieldDiscounted(); break;
|
494 |
case 34 : SetupYieldMaturity(); break;
|
495 |
}
|
496 |
}
|
497 |
//---------------------------------------------------------------------------
|
498 |
void __fastcall TFinCalForm::DisableFields()
|
499 |
{
|
500 |
E1Edit->Enabled = false;
|
501 |
E1Edit->Color = clWhite;
|
502 |
E2Edit->Enabled = false;
|
503 |
E2Edit->Color = clWhite;
|
504 |
E3Edit->Enabled = false;
|
505 |
E3Edit->Color = clWhite;
|
506 |
E4Edit->Enabled = false;
|
507 |
E4Edit->Color = clWhite;
|
508 |
E5Edit->Enabled = false;
|
509 |
E5Edit->Color = clWhite;
|
510 |
I1Edit->Enabled = false;
|
511 |
I1Edit->Color = clWhite;
|
512 |
I2Edit->Enabled = false;
|
513 |
I2Edit->Color = clWhite;
|
514 |
I3Edit->Enabled = false;
|
515 |
I3Edit->Color = clWhite;
|
516 |
I4Edit->Enabled = false;
|
517 |
I4Edit->Color = clWhite;
|
518 |
I5Edit->Enabled = false;
|
519 |
I5Edit->Color = clWhite;
|
520 |
D1Edit->Enabled = false;
|
521 |
D1Edit->Color = clWhite;
|
522 |
D2Edit->Enabled = false;
|
523 |
D2Edit->Color = clWhite;
|
524 |
D3Edit->Enabled = false;
|
525 |
D3Edit->Color = clWhite;
|
526 |
D4Edit->Enabled = false;
|
527 |
D4Edit->Color = clWhite;
|
528 |
D5Edit->Enabled = false;
|
529 |
D5Edit->Color = clWhite;
|
530 |
DAEdit->Enabled = false;
|
531 |
DAEdit->Color = clWhite;
|
532 |
VAEdit->Enabled = false;
|
533 |
VAEdit->Color = clWhite;
|
534 |
StrEdit->Enabled = false;
|
535 |
StrEdit->Color = clWhite;
|
536 |
TimEdit->Enabled = False;
|
537 |
TimEdit->Color = clWhite;
|
538 |
BasEdit->Enabled = False;
|
539 |
BasEdit->Color = clWhite;
|
540 |
FreqEdit->Enabled = False;
|
541 |
FreqEdit->Color = clWhite;
|
542 |
BoolEdit->Enabled = false;
|
543 |
BoolEdit->Color = clWhite;
|
544 |
}
|
545 |
//---------------------------------------------------------------------------
|
546 |
void __fastcall TFinCalForm::ExtEditExit(TObject *Sender)
|
547 |
{
|
548 |
TEdit* edit = (TEdit*) Sender;
|
549 |
ExtVar[edit->Tag] = edit->Text.ToDouble();
|
550 |
}
|
551 |
//---------------------------------------------------------------------------
|
552 |
void __fastcall TFinCalForm::IntEditExit(TObject *Sender)
|
553 |
{
|
554 |
TEdit* edit = (TEdit*) Sender;
|
555 |
IntVar[edit->Tag] = edit->Text.ToInt();
|
556 |
}
|
557 |
//---------------------------------------------------------------------------
|
558 |
void __fastcall TFinCalForm::DateEditExit(TObject *Sender)
|
559 |
{
|
560 |
TEdit* edit = (TEdit*) Sender;
|
561 |
DateVar[edit->Tag] = DateStringToStDate("mm/dd/yy", edit->Text, 1920);
|
562 |
}
|
563 |
//---------------------------------------------------------------------------
|
564 |
void __fastcall TFinCalForm::StrEditExit(TObject *Sender)
|
565 |
{
|
566 |
TEdit* edit = (TEdit*) Sender;
|
567 |
StrVar = edit->Text;
|
568 |
}
|
569 |
//---------------------------------------------------------------------------
|
570 |
|
571 |
void __fastcall TFinCalForm::DAEditExit(TObject *Sender)
|
572 |
{
|
573 |
for (int i=0; i<IntVar[0]; i++)
|
574 |
DateArray[i] = DateStringToStDate("mm/dd/yy", DAEdit->Cells[0][i], 1950);
|
575 |
}
|
576 |
//---------------------------------------------------------------------------
|
577 |
void __fastcall TFinCalForm::DAEditEnter(TObject *Sender)
|
578 |
{
|
579 |
DAEdit->Row = 0;
|
580 |
DAEdit->Col = 0;
|
581 |
}
|
582 |
//---------------------------------------------------------------------------
|
583 |
void __fastcall TFinCalForm::VAEditEnter(TObject *Sender)
|
584 |
{
|
585 |
VAEdit->Row = 0;
|
586 |
VAEdit->Col = 0;
|
587 |
}
|
588 |
//---------------------------------------------------------------------------
|
589 |
void __fastcall TFinCalForm::VAEditExit(TObject *Sender)
|
590 |
{
|
591 |
for (int i=0; i<IntVar[0]; i++)
|
592 |
ValArray[i] = VAEdit->Cells[0][i].ToDouble();
|
593 |
}
|
594 |
//---------------------------------------------------------------------------
|
595 |
void __fastcall TFinCalForm::FreqEditExit(TObject *Sender)
|
596 |
{
|
597 |
switch (FreqEdit->ItemIndex) {
|
598 |
case 0: FreqVar = fqAnnual; break;
|
599 |
case 1: FreqVar = fqSemiAnnual; break;
|
600 |
case 2: FreqVar = fqQuarterly; break;
|
601 |
case 3: FreqVar = fqMonthly; break;
|
602 |
}
|
603 |
}
|
604 |
//---------------------------------------------------------------------------
|
605 |
void __fastcall TFinCalForm::BasEditExit(TObject *Sender)
|
606 |
{
|
607 |
switch(BasEdit->ItemIndex) {
|
608 |
case 0: BasVar = BasisNASD; break;
|
609 |
case 1: BasVar = BasisActAct; break;
|
610 |
case 2: BasVar = BasisAct360; break;
|
611 |
case 3: BasVar = BasisAct365; break;
|
612 |
case 4: BasVar = BasisEur30360; break;
|
613 |
}
|
614 |
}
|
615 |
//---------------------------------------------------------------------------
|
616 |
void __fastcall TFinCalForm::TimEditExit(TObject *Sender)
|
617 |
{
|
618 |
switch (TimEdit->ItemIndex) {
|
619 |
case 0: TimVar = ptEndOfPeriod; break;
|
620 |
case 1: TimVar = ptStartOfPeriod; break;
|
621 |
}
|
622 |
}
|
623 |
//---------------------------------------------------------------------------
|
624 |
void __fastcall TFinCalForm::BoolEditExit(TObject *Sender)
|
625 |
{
|
626 |
BoolVar = BoolEdit->Checked;
|
627 |
}
|
628 |
//---------------------------------------------------------------------------
|
629 |
void __fastcall TFinCalForm::FormCreate(TObject *Sender)
|
630 |
{
|
631 |
for (int i=0; i<5; i++) {
|
632 |
ExtVar[i] = 0;
|
633 |
DateVar[i] = CurrentDate();
|
634 |
IntVar[i] = 0;
|
635 |
}
|
636 |
E1Edit->Text = FloatToStr(ExtVar[0]);
|
637 |
E2Edit->Text = FloatToStr(ExtVar[1]);
|
638 |
E3Edit->Text = FloatToStr(ExtVar[2]);
|
639 |
E4Edit->Text = FloatToStr(ExtVar[3]);
|
640 |
E5Edit->Text = FloatToStr(ExtVar[4]);
|
641 |
I1Edit->Text = IntToStr(IntVar[0]);
|
642 |
I2Edit->Text = IntToStr(IntVar[1]);
|
643 |
I3Edit->Text = IntToStr(IntVar[2]);
|
644 |
I4Edit->Text = IntToStr(IntVar[3]);
|
645 |
I5Edit->Text = IntToStr(IntVar[4]);
|
646 |
D1Edit->Text = StDateToDateString("mm/dd/yy", DateVar[0], true);
|
647 |
D2Edit->Text = StDateToDateString("mm/dd/yy", DateVar[1], true);
|
648 |
D3Edit->Text = StDateToDateString("mm/dd/yy", DateVar[2], true);
|
649 |
D4Edit->Text = StDateToDateString("mm/dd/yy", DateVar[3], true);
|
650 |
D5Edit->Text = StDateToDateString("mm/dd/yy", DateVar[4], true);
|
651 |
DisableFields();
|
652 |
for (int i=0; i<30; i++) {
|
653 |
ValArray[i] = 0;
|
654 |
DateArray[i] = CurrentDate();
|
655 |
}
|
656 |
TimEdit->ItemIndex = 0;
|
657 |
TimVar = ptEndOfPeriod;
|
658 |
BasEdit->ItemIndex = 0;
|
659 |
BasVar = BasisNASD;
|
660 |
FreqEdit->ItemIndex = 0;
|
661 |
FreqVar = fqAnnual;
|
662 |
BoolEdit->Checked = false;
|
663 |
BoolVar = false;
|
664 |
Application->HintPause = 250;
|
665 |
Application->HintColor = clAqua;
|
666 |
}
|
667 |
//---------------------------------------------------------------------------
|
668 |
void __fastcall TFinCalForm::BitBtn1Click(TObject *Sender)
|
669 |
{
|
670 |
Close();
|
671 |
}
|
672 |
//---------------------------------------------------------------------------
|