<-- Previous || Up || Next -->

Base X To Number Function
Math Miscellaneous Class

Public Function BaseXToNumber( _
      ByVal vString As Variant _
    , Optional ByVal vBase As Variant _
    ) As Variant

Convert a number whose base is assumed to be vBase into a base-10 Double (precision floating-point) value.

Examples:
    BaseXToNumber("10101011101", 2) = 1373
    BaseXToNumber("23", 8) = 19
    BaseXToNumber("377", 8) = 255
    BaseXToNumber("12345", 8) = 5349
    BaseXToNumber("-3456", 8) = -1838 ' #5
    BaseXToNumber("23", 16) = 35
    BaseXToNumber("FFFF", 16) = 65535
    BaseXToNumber("12345678", 16) = 305419896
    BaseXToNumber("AZ", 36) = 395
    BaseXToNumber("ABC", 36) = 13368
    BaseXToNumber("12345678", 36) = 82906087076
    BaseXToNumber("AZABCDE", 36) = 23901464930
    BaseXToNumber("ABCDEFGHI", 36) = 29100036563766
    BaseXToNumber("ABCDEFGHIJKL", 36) = 1.35769130591909E+18
See also:
    NumberToBaseX Function
    BaseXToLong Function
Summary: This function can convert any numeric string whose base is between 2 and 36. Use base 2 for binary numbers, base 8 for octal numbers, base 10 for decimal numbers, base 16 for hexadecimal numbers, and base 36 for alphanumeric numbers. This function accepts negative numbers as indicated by a leading minus sign ("-") as in example #5.

vString: String containing the number in base vBase which will be converted to base 10 and returned as a Double value. Function returns Null if vString is Null or cannot be fixed up to a String.

vBase: The number base from which vString will be converted to base 10. vBase defaults to 10 (ten) if it is missing or Null or cannot be fixed up to a number. Function sets the base to 2 if vBase is less than 2.

Note: Function ignores characters in vString which are outside the range of those required to represent numbers of the specified base. For example, if the base if 2, this function will ignore all characters but "0" and "1" (and possibly a leading "-" which would indicate a negative number).

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.