Option Explicit
Function BuHao(SoLg As Double, NhomSF As String, Optional InMau As Boolean = True)
Dim FTram As Double
SoLg = SoLg / 1000: NhomSF = UCase$(Trim(NhomSF))
If Left(NhomSF, 1) = "S" Then
If InMau Then
FTram = Switch(SoLg <= 1, 2.8, SoLg <= 3, 2.4, SoLg <= 5, 1.8, SoLg <= 10, 1.44, _
SoLg <= 15, 1.26, SoLg > 15, 1)
Else
FTram = Switch(SoLg <= 1, 2.5, SoLg <= 3, 1.7, SoLg <= 5, 1.5, SoLg <= 10, 1.2, _
SoLg <= 15, 1, SoLg > 15, 0.75)
End If
ElseIf Left(NhomSF, 2) = "BI" Then
If InMau Then
FTram = Switch(SoLg <= 1, 2.8, SoLg <= 3, 2.4, SoLg <= 5, 2, SoLg <= 10, 1.4, _
SoLg <= 15, 1.2, SoLg > 15, 1)
Else
FTram = Switch(SoLg <= 1, 2, SoLg <= 3, 1.6, SoLg <= 5, 1.4, SoLg <= 10, 1, _
SoLg <= 15, 0.75, SoLg > 15, 0.6)
End If
Else 'Bao chi'
If InMau Then
FTram = Switch(SoLg <= 1, 2.3, SoLg <= 3, 2, SoLg <= 5, 1.7, SoLg <= 10, 1.3, _
SoLg <= 15, 1.2, SoLg > 15, 1)
Else
FTram = Switch(SoLg <= 1, 2, SoLg <= 3, 1.6, SoLg <= 5, 1.4, SoLg <= 10, 1#, _
SoLg <= 15, 0.75, SoLg > 15, 0.6)
End If
End If
BuHao = SoLg * 10 * FTram
End Function