Convert a Decimal Number to Any Base (Bin, Oct, Hex)

Category:
Dates and Math
Type:
Snippets
Difficulty:
Intermediate
Author:
Anonymous

Version Compatibility: Visual Basic 6, Visual Basic 5

More information:
I needed code to convert a decimal number to various different bases, mainly binary and hexadecimal. This is the code I devised. It will only work with positive integers, and I am unsure of the upper range which this will work. I will try and add additional functionality to deal with decimal and negative numbers. There is a Form_Load procedure to demo this out of the box.

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: