Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

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
Asked:
grib01
1 Solution
 
khaledcCommented:
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
For more information see also help in VB under Oct, Hex, CLng.
Hope this answered your question.
One more thing there is no direct way to convert a number into a binary string representation.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now