Function Math Miscellaneous Class

DirectionToDegrees

Converts the abbreviation for a compass direction (N, SW, ENE, etc.) into a measurement in degrees (between 0 and 360).

Signature (Visual Basic / VBA)

Public Function DirectionToDegrees( _
    ByVal vDirection As Variant _
    ) As Variant

Code Example

    DirectionToDegrees("N") = 0
    DirectionToDegrees("SW") = 225
    DirectionToDegrees("ENE") = 67.5
    DirectionToDegrees("WHAT") = -1 ' #4.
    DirectionToDegrees("EW") = -1 ' #5.

Parameters

Parameter Description
vDirection String containing an abbreviation for one of the 16 possible compass directions. Function returns Null if vDirection is Null of cannot be fixed up to a String.

Notes & Version History

Note These are the well-formed directions accepted by this function: E, ENE, ESE, N, NE, NNE, NNW, NW, S, SE, SSE, SSW, SW, W, WNW, and WSW. Function returns -1 if vDirection is not one of those sixteen direction abbreviations as in examples #4 and #5.