Trying to get percentage from VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can anyone tell me what I am doing wrong here to figure
percent? I tried to use all sorts of declrations but
cannot figure it out. Code is below

Private Sub SampleWeight_AfterUpdate()

'After the weight has been entered, figure the
percentage off (+/- 10)
x = Me.SampleWeight.Value
y = Me.Text156.Value
Tolerance = (x - y) / y
If Tolerance > 10 Then
Me.Text154.Value = "The percentage is over 10% ( "
& Tolerance & "% )"
ElseIf Tolerance < -10 Then
Me.Text154.Value = "The percentage is under 10%
( " & Tolerance & "% )"
Else
Me.Text154.Value = "The weight is within
specification"
End If

End Sub
 
Back
Top