01.
02.
03.
04.
05.
Private
Sub
SetValue()
06.
07.
08.
txtAssetPrice.Text =
"1000"
09.
txtUseYearAge.Text = 5
10.
txtRecAsset.Text =
"01/02/2553"
11.
12.
Dim
TD
As
DateTime = Today
13.
14.
If
txtAssetPrice.Text =
String
.Empty
Then
txtAssetPrice.Text = 0
15.
16.
If
txtUseYearAge.Text =
String
.Empty
Then
txtUseYearAge.Text = 0
17.
18.
19.
txtDepreciationPerYearPrice.Text = Strings.Format(
CDbl
(txtAssetPrice.Text) /
CDbl
(txtUseYearAge.Text),
"#,##0.00"
)
20.
21.
Dim
YearTotal
As
Integer
= 0
22.
23.
Dim
MonthTotal
As
Integer
= 0
24.
25.
If
txtRecAsset.Text =
String
.Empty
Then
txtRecAsset.Text = thDate(Strings.Format(Today,
"dd/MM/yyyy"
))
26.
27.
28.
Dim
USDATES
As
String
= USDate(txtRecAsset.Text)
29.
30.
31.
USDATES = Strings.Mid(USDATES, 4, 2) &
"/"
& Strings.Left(USDATES, 2) &
"/"
& Strings.Right(USDATES, 4)
32.
33.
34.
Dim
RecAsset
As
DateTime = USDATES
35.
36.
37.
Dim
DayTotal
As
Integer
= ((DateDiff(DateInterval.Day, RecAsset, Today)) + 1)
38.
39.
40.
YearTotal = DayTotal \ 365
41.
42.
DayTotal = DayTotal - (YearTotal * 365)
43.
44.
MonthTotal = (DayTotal \ 30)
45.
46.
DayTotal = DayTotal - (MonthTotal * 30)
47.
48.
DayTotal = DayTotal
Mod
30
49.
50.
51.
Dim
YearPrice
As
Double
= (
CDbl
(txtAssetPrice.Text) /
CDbl
(txtUseYearAge.Text)) *
CDbl
(YearTotal)
52.
53.
Dim
MonthPrice
As
Double
= (
CDbl
(txtAssetPrice.Text) /
CDbl
(txtUseYearAge.Text) / 12) * MonthTotal
54.
55.
Dim
DayPrice
As
Double
= ((
CDbl
(txtAssetPrice.Text) /
CDbl
(txtUseYearAge.Text) / 12) / 30) * DayTotal
56.
57.
58.
txtDepreciationTotal.Text = Strings.Format(
CDbl
(YearPrice + MonthPrice + DayPrice),
"#,##0.00"
)
59.
60.
61.
txtAssetValue.Text = Strings.Format((
CDbl
(txtAssetPrice.Text) - (YearPrice + MonthPrice + DayPrice)),
"#,##0.00"
)
62.
63.
64.
txtAmountYear.Text = YearTotal
65.
66.
txtAmountMonth.Text = MonthTotal
67.
68.
txtDay.Text = DayTotal
69.
70.
71.
If
CDbl
(txtDepreciationTotal.Text) >
CDbl
(txtAssetPrice.Text)
Then
72.
73.
txtDepreciationTotal.Text = Strings.Format(
CDbl
(txtAssetPrice.Text),
"#,##0.00"
)
74.
75.
76.
txtAssetValue.Text = 0
77.
78.
End
If
79.
80.
End
Sub