Hi Everyone!
I admit this is my first attempt at writing case statements, and I am not sure I have my head around it. I am trying to calculate various measurements; ie: square feet, cubic feet, linear feet, cubic feet, cubic yards. Is my statement correct? My numbers are not coming out right at all!
Thank you in advance.
Code:
Private Sub Height_AfterUpdate()
On Error GoTo errHandler
Select Case MeasurementType
Case "cuyd"
TotalMeasurement = Length * Width * Height / 27
'TotalMeasurement = Int(-100 * [TotalMeasurement]) / -100
Case "lf"
TotalMeasurement = Length * 1
'TotalMeasurement = Int(-100 * [TotalMeasurement]) / -100
Case "sqft"
TotalMeasurement = Length * Width
'TotalMeasurement = Int(-100 * [TotalMeasurement]) / -100
Case "cuft"
TotalMeasurement = Length * Width * Height
'TotalMeasurement = Int(-100 * [TotalMeasurement]) / -100
Case "sqyd"
TotalMeasurement = Length * Width / 9
'TotalMeasurement = Int(-100 * [TotalMeasurement]) / -100
End Select
Dim numvalue As Double
numvalue = [TotalMeasurement]
If (numvalue - Int(numvalue)) = 0 Then
Exit Sub
Else
numvalue = Int(numvalue) + 1
'MsgBox numvalue ' display the new value
'[Value1] = numvalue
End If
Exit Sub
errHandler:
MsgBox "Error " & Err.Number & ": " & Err.Description & " in " & _
VBE.ActiveCodePane.CodeModule, vbOKOnly, "Error"
End Sub