+ Reply to Thread
Results 1 to 12 of 12

Different number base system

  1. #1
    Forum Contributor
    Join Date
    02-12-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    275

    Different number base system

    I need a macro that will convert a number from decimal to binary, octave, and Hexadecimal.

    and another to convert it back.

    This conversion must take place between a variable and user form and back to the variable.

    please help

    Thanks

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Different number base system

    Search Excel help for the DEC2BIN(), OCT2BIN(), HEX2BIN(), etc. I'm pretty sure all those functions are built into Excel.

  3. #3
    Forum Contributor
    Join Date
    02-12-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    275

    Re: Different number base system

    In excel on a spread sheet yes and also very easy.

    In a macro with NO spreadsheet, that is not so easy to do.

  4. #4
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Different number base system

    VBA has built in functions which will convert to and from Octal and Hexadecimal numbers.

    By Binary I assume you mean a binary representation string of 1s and 0s, because all numbers are binary in a computer.

    If you googled the topic you would find a number of example codes already out there, such as:
    http://www.devhut.net/2010/06/22/vba...al-and-binary/

  5. #5
    Forum Contributor
    Join Date
    02-12-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    275

    Re: Different number base system

    Thanks Steven. This helps a lot. Now I must just learn how to use a functions.

  6. #6
    Forum Contributor
    Join Date
    02-12-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    275

    Re: Different number base system

    It still leaves me with the octave and hexadecimal and my google searches does not seem to be as effective.

  7. #7
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Different number base system

    Please Login or Register  to view this content.
    You must add "&H" to a Hex string and "&O" to a Oct string. Other than that, it is fairly simple.

  8. #8
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Different number base system

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    02-12-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    275

    Re: Different number base system

    I was looking for the easy solution. and it seems that CBase is the answer.

    use it as any of the other functions like mid or len

    Please Login or Register  to view this content.
    use
    2 for binary
    8 for octave
    10 for decimal
    16 for Hexadecimal

  10. #10
    Forum Contributor
    Join Date
    02-12-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    275

    Re: Different number base system

    I was mistaken and in my trials inserted a Function called CBase and that is what made it work.

    This Function works towards a spreadsheet

    So. In other words. I still need help.

    To convert number values to and from other base structures to decimal without the aid of a spreadsheet.

    Thanks

  11. #11
    Valued Forum Contributor StevenM's Avatar
    Join Date
    03-23-2008
    Location
    New Lenox, IL USA
    MS-Off Ver
    2007
    Posts
    910

    Re: Different number base system

    You need the two functions which I posted earlier (Bin2Dec & Dec2Bin).
    And it only works for base 2, 8, 10, & 16.

    Please Login or Register  to view this content.

  12. #12
    Forum Contributor
    Join Date
    02-12-2012
    Location
    South Africa
    MS-Off Ver
    Excel 2007
    Posts
    275

    Re: Different number base system

    Thanks I will try it not that I have any doubt that it will work once I know what I'm doing.

    Thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1