01.
Private
Sub
UpdateLabelText()
02.
Dim
WithdrawalTotal
As
Integer
= 0
03.
Dim
DepositTotal
As
Integer
= 0
04.
Dim
SelectedCellTotal
As
Integer
= 0
05.
Dim
counter
As
Integer
06.
07.
08.
For
counter = 0
To
(DataGridView1.Rows.Count) - 1
09.
If
DataGridView1.Rows(counter).Cells(
"Withdrawals"
).Value IsNot
Nothing
Then
10.
If
DataGridView1.Rows(counter).Cells(
"Withdrawals"
).Value.ToString().Length <> 0
Then
11.
WithdrawalTotal +=
Integer
.Parse(DataGridView1.Rows(counter).Cells(
"Withdrawals"
).Value.ToString())
12.
End
If
13.
End
If
14.
15.
If
DataGridView1.Rows(counter).Cells(
"Deposits"
).Value IsNot
Nothing
Then
16.
If
DataGridView1.Rows(counter).Cells(
"Deposits"
).Value.ToString().Length <> 0
Then
17.
DepositTotal +=
Integer
.Parse(DataGridView1.Rows(counter).Cells(
"Deposits"
).Value.ToString())
18.
End
If
19.
End
If
20.
Next
21.
22.
23.
For
counter = 0
To
(DataGridView1.SelectedCells.Count) - 1
24.
If
DataGridView1.SelectedCells(counter).FormattedValueType = Type.[
GetType
](
"System.String"
)
Then
25.
Dim
value
As
String
=
Nothing
26.
27.
28.
29.
If
DataGridView1.IsCurrentCellDirty =
True
Then
30.
31.
value = DataGridView1.SelectedCells(counter).EditedFormattedValue.ToString()
32.
Else
33.
value = DataGridView1.SelectedCells(counter).FormattedValue.ToString()
34.
End
If
35.
If
value IsNot
Nothing
Then
36.
37.
If
DataGridView1.SelectedCells(counter).ColumnIndex <> DataGridView1.Columns(
"Description"
).Index
Then
38.
If
value.Length <> 0
Then
39.
SelectedCellTotal +=
Integer
.Parse(value)
40.
End
If
41.
End
If
42.
End
If
43.
End
If
44.
Next
45.
46.
47.
Label1.Text =
"Withdrawals Total: "
& WithdrawalTotal.ToString()
48.
Label2.Text =
"Deposits Total: "
& DepositTotal.ToString()
49.
Label3.Text =
"Selected Cells Total: "
& SelectedCellTotal.ToString()
50.
Label4.Text =
"Total entries: "
& DataGridView1.RowCount.ToString()
51.
End
Sub