The problem is two fold: First, you don't appear to set a value of
count
so there is no guarantee that it is anything like what you want - I would suggest that you should set it to myTable.Rows.Count, or set it to zero and increment it in the loop.
More importantly, you are doing integer arithmetic! So if
ccount22
is 8, and
count
is 10, then
count22 / count
Will be
8 / 10
which in integer arithmetic is zero.
There are two things you can do here - swap to explicit float or double, or ahcnge the calculation to make it work with integers:
Me.txtTI.Text = ((ccount22 * 100) / count00).ToString() & "%"
Because you do the multiply first, you end up with
800 / 10
Which is 80, and correct.
BTW: You do realize that your second line within the loop does absolutely nothing useful, don't you? :laugh:
If b.Item("TI (Y/N)").ToString.ToUpper = "N" Then ccount55 += 0
Try:
If b.Item("TI (Y/N)").ToString.ToUpper = "N" Then ccount55 += 1
Instead...
BTW2: That isn't a "nice" way to do it anyway; this is easier to read and a lot more efficient:
For Each b As DataRow In myTable.Rows
Dim YesNo as string = b.Item("TI (Y/N)").ToString.ToUpper
If YesNo = "Y" Then ccount22 += 1
If YesNo = "N" Then ccount55 += 0
Next