R
Ryan H
Why am I getting a Type Mismatch error an the line indicated below when call
the function? Thanks in advance!!!
Sub Test()
' test if dimensions are rounded to nearest 16th
Error>>> If InvalidDimensions(tbxHeightFt, tbxHeightIns, tbxWidthFt,
tbxWidthIns) Then
MsgBox "Please round all dimensions to the nearest 1/16''.",
vbCritical
StopCode = True
Exit Sub
End If
End Sub
' ensure dimensions must be rounded to the nearest 1/16th of an inch
Function InvalidDimensions(Hft As Single, Hins As Single, _
Wft As Single, Wins As Single, _
Optional Dft As Single, Optional Dins As Single)
As Boolean
' height
If (Hft = 0 And Hins = 0) Or _
((Hft * 12 + Hins) * 16 <> Int(Hft * 12 + Hins) * 16) Then
InvalidDimensions = True
Exit Function
End If
' width
If (Wft = 0 And Wins = 0) Or _
((Wft * 12 + Wins) * 16 <> Int(Wft * 12 + Wins) * 16) Then
InvalidDimensions = True
Exit Function
End If
' width
If Not IsMissing(Dft) Or Not IsMissing(Dins) Then
If (Dft = 0 And Dins = 0) Or _
((Dft * 12 + Dins) * 16 <> Int(Dft * 12 + Dins) * 16) Then
InvalidDimensions = True
Exit Function
End If
End If
End Function
the function? Thanks in advance!!!
Sub Test()
' test if dimensions are rounded to nearest 16th
Error>>> If InvalidDimensions(tbxHeightFt, tbxHeightIns, tbxWidthFt,
tbxWidthIns) Then
MsgBox "Please round all dimensions to the nearest 1/16''.",
vbCritical
StopCode = True
Exit Sub
End If
End Sub
' ensure dimensions must be rounded to the nearest 1/16th of an inch
Function InvalidDimensions(Hft As Single, Hins As Single, _
Wft As Single, Wins As Single, _
Optional Dft As Single, Optional Dins As Single)
As Boolean
' height
If (Hft = 0 And Hins = 0) Or _
((Hft * 12 + Hins) * 16 <> Int(Hft * 12 + Hins) * 16) Then
InvalidDimensions = True
Exit Function
End If
' width
If (Wft = 0 And Wins = 0) Or _
((Wft * 12 + Wins) * 16 <> Int(Wft * 12 + Wins) * 16) Then
InvalidDimensions = True
Exit Function
End If
' width
If Not IsMissing(Dft) Or Not IsMissing(Dins) Then
If (Dft = 0 And Dins = 0) Or _
((Dft * 12 + Dins) * 16 <> Int(Dft * 12 + Dins) * 16) Then
InvalidDimensions = True
Exit Function
End If
End If
End Function