Converting from Base N to Base X
By Alex Morgan and Claude RubinsonVBScript does not natively support Base N notation or calculations; nevertheless, since both SQL and COM objects support Base N, the ability to convert from decimal (Base 10) format to Base N (and vice versa) is sometimes necessary.
Three scripts are developed below. The first converts from Base N to decimal. The second, from decimal to Base N. The third utilizes the previous functions to permit conversion between any two bases (Base N to Base X).
There are a few issues to be aware of. First, the scripts are caseinsensitive. Specifically, all lowercase characters are converted to uppercase before being processed. Second, the supplied value may be specified either as numeric or text (just be sure to include the quotes when specifying values as text!). Third, the inBase
and outBase
must be specified as integers. Base A would be specified as 10; Base B, as 11; etc. Finally, the scripts have an upperbound limit of Base Z. Please note that we have not included errortrapping in these functions; you may wish to.
Happy Programming!
