What is this supposed to do?
myValue = (.............)
Main Topics
Browse All TopicsUsers currently use the following code to compare two values ....
Private Sub txt_B_Exit(Cancel As Integer)
Dim myLimit, myValue, myTol
myLimit = 10
myTol = 0.00005
If Nz(Me.txt_B) < myLimit Then
MsgBox "Sqarefeetvalues below " & myLimit & " are not possible in this context!", vbExclamation
Cancel = True
Else
'Calculate formula
myValue = (.............)
myValue = Round(myValue, 5)
' Compare result with tolerance '<<----- Critcal point
If Abs(myValue - Me.txt_A.Value) > myTol Then
MsgBox "The calculatd Value is " & myValue, vbCritical
Me.txt_A.SetFocus
Else
Me.Verified = True
Me.txt_C.SetFocus
End If
End If
End Sub
**************************
Our office usually round off to 5 decimal places all the time during data entry but adhere to the 3 decimal places when compiling a report. Most of the Engineers / Architects who request for permits from us usually round off to 3 decimal places when submiting their value of their new project "Flow" for us to validate.
Assuming that an Engineer submitted a flow of 0.006 but the auto calculated value
came out to be 0.00561.
In actual sense, the value of 0.006 submitted by the Engineer is correct if 0.00561 was
rounded off to 3 decimal places.
Using tolerance of value > 0.00005 through 0.00099 did not resolve the 3 decimal places
and as a result, the autocalculated value of 0.000561 did not accept the 0.00600 as correct or equals to 0.00561.
QUESTION?
In this scenerio, in what way can I adjust the tolerance value to recond the following:
if the autocalculated value is 0.00561 then
(a). Accept the rounding off to 0.00600
(b) Deny rounding off to 0.00610
(c).Deny rounding off to 0.00500
(d). Accept rounding to 0.00560
(f). Deny rounding to 0.00562 since it was greater than the original
calculated value of 0.00561
Well, I am not too sure if the above is achievable, I was only pondering on it.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Private Sub txt_B_Exit(Cancel As Integer)
Dim myLimit, myValue, myTol
myLimit = 10
--------------------------
--------------- this is replaced >>>>>>>> myTol = 0.00005
If Int(myValue*10000)<>myValu
myTol = 0.00005
Goto conhere
End If
If Int(myValue*1000)<>myValue
myTol = 0.0005
Goto conhere
End If
If Int(myValue*100)<>myValue*
myTol = 0.005
Goto conhere
End If
conhere:
--------------------------
If Nz(Me.txt_B) < myLimit Then
MsgBox "Sqarefeetvalues below " & myLimit & " are not possible in this context!", vbExclamation
Cancel = True
Else
'Calculate formula
myValue = (.............)
myValue = Round(myValue, 5)
' Compare result with tolerance '<<----- Critcal point
If Abs(myValue - Me.txt_A.Value) > myTol Then
MsgBox "The calculatd Value is " & myValue, vbCritical
Me.txt_A.SetFocus
Else
Me.Verified = True
Me.txt_C.SetFocus
End If
End If
End Sub
the 3 if-statements look, if the last significant decimal is 5th, 4th or 3rd digit and set the tollerance acordingly
regards, Franz
Franz,
I ran a quick test with the following values and still have some problems with the auto calculation and the compared value:
I selected R3-2; and entered 2465 in my formular (not shown here)
Engineer's flow data = 0.003 (rounded to to 3 d(to 5 decimal places).
Auto calculated flow value = 0.00261(to 5 decimal places)
Judging by the two values above, both the Engineer's flow value and the autocalculated value are correct but the code above still presented me with a msgbox as if the Engineer's value was wrong.
Am I doing something wrong?
Regards
Bill
Hi Bill,
sorry for the mistake. In the added lines we need to check on Me.SanFlow not on myValue
so the correct version would be:
Private Sub txtSqft_Exit(Cancel As Integer)
Dim myLimit, myValue, myTol
myLimit = 10
myTol = 0.00005
If Nz(Me.txtSqft) < myLimit Then
MsgBox "Sqarefeetvalues below " & myLimit & " are not possible in this context!", vbExclamation
Cancel = True
Else
' Calculate formula
myValue = CDbl(Me.Zonetxt.Column(1))
myValue = Round(myValue, 5)
' Compare result with tolerance
'-------------------------
'--------------- this is replaced >>>>>>>> myTol = 0.00005
If Int(Me.SanFlow * 10000) <> Me.SanFlow * 10000 Then
myTol = 0.00005
GoTo conhere
End If
If Int(Me.SanFlow * 1000) <> Me.SanFlow * 1000 Then
myTol = 0.0005
GoTo conhere
End If
If Int(Me.SanFlow * 100) <> Me.SanFlow * 100 Then
myTol = 0.005
GoTo conhere
End If
conhere:
'-------------------------
If Abs(myValue - Me.SanFlow) > myTol Then
MsgBox "The calculatd SanFlow-Value is " & myValue, vbCritical
Me.txtSanFlow.SetFocus
Else
Me.Verified = True
Me.txtPermitNo.SetFocus
Me.Zonetxt.Visible = False
Me.txtSqft.Visible = False
Me.SanFlowVerify.Visible = False
End If
End If
End Sub
--------------------------
please note, that the code does not exactly do, what you required, but the result is nearly the same
to do exactly what you required, we would skip the tollerance and round the myvalue to the decimalplaces, which have been entered
regards, Franz
Business Accounts
Answer for Membership
by: bonjour-autPosted on 2007-08-19 at 08:38:50ID: 19726044
Hi Bill,
e*10000 Then *1000 Then 100 Then
Probably simplest way may be:
If Int(myValue*10000)<>myValu
myTol = 0.00005
Goto conhere
End If
If Int(myValue*1000)<>myValue
myTol = 0.0005
Goto conhere
End If
If Int(myValue*100)<>myValue*
myTol = 0.005
Goto conhere
End If
conhere:
...
...
Regards, Franz