Function Units Class ★ Top 20 Most Useful

ConvertMeasure

"Convert Measurement" Convert a measurement to some other type of measurement. For example, convert 1/5 ft/s (feet per second) to mph (miles per hour).

Signature (Visual Basic / VBA)

Public Function ConvertMeasure( _
      ByVal vFromValue As Variant _
    , ByVal vFromUnits As Variant _
    , ByVal vToUnits As Variant _
    ) As Variant

Code Examples

    ConvertMeasure(5, "feet", "meters")
    ConvertMeasure(5, "ft*lb/s^2", "Newtons")
    ConvertMeasure(23, "lbf", "")

Return Value

The function returns a numeric result when the vFromUnits and vToUnits expressions represent the same type of physical measurements. It returns a string of the form "12 meters" when the vFromUnits and vToUnits do NOT represent the same type of physical measurement. When errors occur, the error message is returned as a string of the form "Error: ...." The function returns Null when all three of its arguments are Null. Remaining Units : The setting of the estConvertToBaseUnits global variable controls how remaining units will be returned. Remaining units will be returned in the standard SI measurement for the category when this setting is False, and they will be returned as a combination of base SI units when the setting is True. converts 5 feet into meters, returning 1.524. converts 5 foot-pounds per second squared into Newtons, returning .6912. converts 23 pounds-force into either newtons or kilogram meters per second squared, depending upon to the setting of the estConvertToBaseUnits global variable.

Notes & Version History

Remarks This function performs measurement conversions given a numeric measurement, the units of that measurement, and the desired units for the result.
Arguments vFromValue can be any type of numeric value, including decimal/fractional numbers or dates which are a represented as strings. vToUnits and vFromUnits are assumed to be strings containing symbolic measurement expressions.