hi all,
im currently creating a program that will calculate averages of 3 different numbers which, when calculated the answer is ouputted to a text box, what i need and cannot get is that obviously averaging by 3 you will get a decimal answer eg 1.6 etc, what i need to calculate or do is that if the textbox value = 0.6 and less it equals 0 then also if textbox value = greater than 0.7 but less than 1.6 then that will equal 1, then in turn > 1.7 < 2.6 = 2 and >2.7 <3.6 = 3 and >3.7 < 4.6 = 4 and lastly > 4.7 <5.6 = 5
ive tried using math.ceiling and floor but do not know how to round up and round down depending on those particular values
can any one please shed some light on this issue as its very urgent!
Thanks in advance
Luke :)
Loading
Karthikeyan AnbarasanPosted Apr 8, 2011, 3:31 AM
FroglegPosted Mar 22, 2011, 3:52 AM
Imports System.Math
Public Class Form1
Dim dec1, dec2, dec3, decAnswer As Decimal
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = 9
TextBox2.Text = 7
TextBox3.Text = 5
End Sub
Private Sub bttnAverage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bttnAverage.Click
dec1 = TextBox1.Text
dec2 = TextBox2.Text
dec3 = TextBox3.Text
decAnswer = (((dec1 + dec2 + dec3) / 3))
TextBox4.Text = Decimal.Round(decAnswer, 0)
End Sub
End Class