There is a weight measurment which gives us different numbers. But there is always a standard weight for example: 100, so then the Min-Max will be /- 10%. (90 - 110).
The code's job is to tell if it's OK or NOT. Like if it's 89.9 then it's NOT GOOD, but if it's 99.2 it should be OK.
Sometimes a problem occur for no reason, because even if it's on the scale it goes NOT GOOD, and sometimes it's outside of the scale and it goes OK.
The code's part where it's important is here; (Not mine code, I just have to fix it somehow)
If Val(txtWeight.Value) < Val(txtMinWeight.Value) Or Val(txtWeight.Value) > Val(txtMaxWeight.Value) Then
lblJudgement.Caption = "NOT GOOD"
Sheets("Measurment").Cells(j, 2).Value = "NOT GOOD"
lblJudgement.BackColor = 255
txtWeight.BackColor = 255
Call BadSound
Else
lblJudgement.Caption = "OK"
Sheets("Measurment").Cells(j, 2).Value = "OK"
lblJudgement.BackColor = 49152
txtWeight.BackColor = 49152
Call GoodSound
End If
As long as I see it, all the formulas, calculations should be good, so I have no clue why does it turns around sometimes and give back wrong judgements.
If any other information is needed, please let me know!
Thank y'all in advance!
CodePudding user response:
The Val function recognizes only the period ( . ) as a valid decimal separator. When different decimal separators are used, as in international applications, use CDbl instead to convert a string to a number. Microsoft Val function