• Status: Solved
• Priority: Medium
• Security: Public
• Views: 288

# Numeric Conversion Algorithms in VB

I need to figure out an algorithm (or algorithms) for converting a variable (string) from decimal to hexadecimal, binary, and/or octal.
0
grib01
1 Solution

Commented:
If I get you right, First you have to convert a string to a decimal, then from decimal to hexadecimal, binary or octal.
First, you can convert to decimal by using CLng(YourString),  then uses Hex or Oct function to convert hexadecimal or octal as followed:
Dim MyLong as Long
Dim MyStr as string
MyLong=cLng(YourString)
MyStr = Hex(MyLong)      'Or to convert to Octal
MyStr = Oct(MyLong)     'Oct and Hex return a string representation of an octal or hexadecima number
One more thing there is no direct way to convert a number into a binary string representation.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.