| conversion argument | converts: |
|---|---|
| cm-in | centimeters to inches |
| cm-ft | centimeters to feet |
| m-in | meters to inches |
| m-yd | meters to yards |
| km-mi | kilometers to miles |
| g-oz | ounces to grams |
| g-lbs | grams to pounds |
| kg-oz | kilograms to ounces |
| kg-lbs | kilograms to pounds |
| l-pt | liters to pint |
| l-qt | liters to quarts |
| l-gal | liters to gallons |
| Extensiontype argument (integer) | extension |
|---|---|
| 0 | no extension (answer will be a number only) |
| 1 | append the standard abbreviation (lbs for pounds, in for inches, etc...) |
| 2 | append the word (pounds, inches, etc...) |
string = MetricToStandard(metricmeasure,
conversion, extensiontype)
Example Usage:
ASP Source Code:<% ' translate 1g to ounces - no extension response.write MetricToStandard(1, "g-oz", 0) & "<BR>" ' returns 0.04 ' translate 1 kg to miles - abbreviated extension response.write MetricToStandard(1, "km-mi", 1) & "<BR>" ' returns 0.62 mi ' translate 1 cm to feet - full extension response.write MetricToStandard(1, "cm-ft", 2) & "<BR>" ' returns 0.03 feet %>
<%
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
%>