WorksheetFunction.Convert(Object, Object, Object) Method

Definition

Converts a number from one measurement system to another. For example, Convert can translate a table of distances in miles to a table of distances in kilometers.

public:
 double Convert(System::Object ^ Arg1, System::Object ^ Arg2, System::Object ^ Arg3);
public double Convert (object Arg1, object Arg2, object Arg3);
Public Function Convert (Arg1 As Object, Arg2 As Object, Arg3 As Object) As Double

Parameters

Arg1
Object

The value in from_units to convert.

Arg2
Object

The units for number.

Arg3
Object

The units for the result. Convert accepts the following text values (in quotation marks) for from_unit and to_unit which are listed in the Remarks section below.

Returns

Remarks

Gram"g"
Slug"sg"
Pound mass (avoirdupois)"lbm"
U (atomic mass unit)"u"
Ounce mass (avoirdupois)"ozm"
Meter"m"
Statute mile"mi"
Nautical mile"Nmi"
Inch"in"
Foot"ft"
Yard"yd"
Angstrom"ang"
Pica (1/72 in.)"Pica"
Year"yr"
Day"day"
Hour"hr"
Minute"mn"
Second"sec"
Pascal"Pa" (or "p")
Atmosphere"atm" (or "at")
mm of Mercury"mmHg"
Newton"N"
Dyne"dyn" (or "dy")
Pound force"lbf"
Joule"J"
Erg"e"
Thermodynamic calorie"c"
IT calorie"cal"
Electron volt"eV" (or "ev")
Horsepower-hour"HPh" (or "hh")
Watt-hour"Wh" (or "wh")
Foot-pound"flb"
BTU"BTU" (or "btu")
Horsepower"HP" (or "h")
Watt"W" (or "w")
Tesla"T"
Gauss"ga"
Degree Celsius"C" (or "cel")
Degree Fahrenheit"F" (or "fah")
Kelvin"K" (or "kel")
Teaspoon"tsp"
Tablespoon"tbs"
Fluid ounce"oz"
Cup"cup"
U.S. pint"pt" (or "us_pt")
U.K. pint"uk_pt"
Quart"qt"
Gallon"gal"
Liter"l" (or "lt")

The following abbreviated unit prefixes can be prepended to any metric from_unit or to_unit.

exa1E+18"E"
peta1E+15"P"
tera1E+12"T"
giga1E+09"G"
mega1E+06"M"
kilo1E+03"k"
hecto1E+02"h"
dekao1E+01"e"
deci1E-01"d"
centi1E-02"c"
milli1E-03"m"
micro1E-06"u"
nano1E-09"n"
pico1E-12"p"
femto1E-15"f"
atto1E-18"a"

If the input data types are incorrect, Convert generates an error.

If the unit does not exist, Convert generates an error.

If the unit does not support an abbreviated unit prefix, Convert generates an error.

If the units are in different groups, Convert generates an error.

Unit names and prefixes are case-sensitive.

Applies to