0

I'm having a problem with the result of the average in my UserForm. So, I have 4 textboxes where the user will input the grades then upon clicking the button, it will get the average of it.

Here's my code:

Dim Total As Double, i As Integer
 
 If IsNumeric(tb_music) Then Total = Total + CDbl(tb_music): i = i + 1
 If IsNumeric(tb_arts) Then Total = Total + CDbl(tb_arts): i = i + 1
 If IsNumeric(tb_pe) Then Total = Total + CDbl(tb_pe): i = i + 1
 If IsNumeric(tb_health) Then Total = Total + CDbl(tb_health): i = i + 1
 
 tb_mapeh.value = Round(Total / i, 0)

I tried to input a grade of 88, 91, 92, and 91. When using a calculator, the result will be 90.5, right? The result of my code above is 90. I need to show the result as 91. Can someone help me?

Any help is highly appreciated. Thank you!

Pᴇʜ
  • 56,719
  • 10
  • 49
  • 73
cjvdg
  • 497
  • 2
  • 15

0 Answers0