 # Asp Programming Code Examples

## Asp > Mathematics Code Examples

### MetricToStandard Function

``` MetricToStandard Function <% Private Function MetricToStandard(ByVal MetricMeasure, _ ByVal Conversion, ByVal ExtensionType) Dim tmp, multiplier, extension, ext Select Case UCase( Conversion ) Case "CM-IN" : multiplier = 0.3937 : _ extension = "inches" : ext = "in" Case "CM-FT" : multiplier = 0.0328 : _ extension = "feet" : ext = "ft" Case "M-IN" : multiplier = 39.37 : _ extension = "inches" : ext = "in" Case "M-YD" : multiplier = 1.093 : _ extension = "yards" : ext = "yd" Case "KM-MI" : multiplier = 0.6210 : _ extension = "miles" : ext = "mi" Case "G-OZ" : multiplier = 0.0350 : _ extension = "ounces" : ext = "oz" Case "G-LBS" : multiplier = 0.0020 : _ extension = "pounds" : ext = "lbs" Case "KG-OZ" : multiplier = 35.274 : _ extension = "ounces" : ext = "oz" Case "KG-LBS" : multiplier = 2.205 : _ extension = "pounds" : ext = "lbs" Case "L-PT" : multiplier = 2.113 : _ extension = "pints" : ext = "pt" Case "L-QT" : multiplier = 1.057 : _ extension = "quarts" : ext = "qt" Case "L-GAL" : multiplier = 0.264 : _ extension = "gallons" : ext = "gal" End Select tmp = FormatNumber(multiplier * MetricMeasure, 2) Select Case CInt(ExtensionType) Case 0 : tmp = Trim( tmp ) Case 1 : tmp = tmp & " " & ext Case 2 : tmp = tmp & " " & extension Case Else : tmp = Trim( tmp ) End Select MetricToStandard = tmp End Function %> ``` 