Results 1 to 14 of 14
  1. #1
    brandonze is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Mar 2011
    Posts
    49

    converting base 32 to base 10?

    Is there a function for converting a base 32 into a base 10???????

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    NO. i doubt it.

    but try some basic math functions, or a combo of them

  3. #3
    brandonze is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Mar 2011
    Posts
    49
    I don't even know where to start

  4. #4
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    Did you really mean Base 2 (not Base 32).

  5. #5
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    do you know what base 10 IS?? if you do, you can write a simple function in vba to work it.

    first of all, how are your numbers stored?? as actuals or numbers written with "10" as a following subscript?? if they are ACTUALS, here is an example of a conversion from base 32 to 10:

    e.g. ---- 200 (base 32) = (2 * 32^2) + (0 * 32^1) + (0 * 32^0) = whatever + 0 + 0 = whatever

    e.g. ---- 200 (base 10) = (2 * 10^2) + (0 * 10^1) + (0 * 10^0) = 200 + 0 + 0 = 200

    so that's where you start. follow?? I could help ya write it, but I'm busy at the moment. But that's how BASE numbers work!

  6. #6
    brandonze is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Mar 2011
    Posts
    49
    Thank you for the explanation, but the numbers that I have are numbers and letters.

    For example, 3LNJ8L is 123456789.

    That is where I am getting confused.

  7. #7
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    well I have no idea what that means sir. If it's mathematically based, I don't know what the conversion code is. but if you already have an example of it, as you just showed us, then that must mean that you already have the numerical conversions for all of your alpha-numeric strings?? If you've got letters higher than "F" then obviously it's not hexidecimal based.

    if you do, then you can simply use the math I already gave you. right??

  8. #8
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91

    I don't know if I can do this

    All of the below is based on me working out how 3LNJ8L works into 123456789. If I made a math mistake then the below is rubbish.

    If I am doing this correctly Base 32 means using numbers 0 - 9 and letters A - V (Base 36 = 0 - 9 and A - Z). Therefore 0 - 9 represent 0 - 9, A = 10, B = 11, C = 12 and so forth until V = 31.

    A. Thus 3LNJ8L works out to represent [3] [21] [23] [19] [8] and [21].

    B. Each position of 3LNJ8L represents a power of 32:
    Far right digit(L) = 32^0 = 1
    Next digit to the left (8) = 32^1 = 32
    Next digit to the left (J) = 32^2 = 1,024
    Next digit to the left (N) = 32^3 = 32,768
    Next digit to the left (L) = 32^4 = 1,048,576
    Next digit to the left (3) = 32^5 = 33,554,432

    C. So now multiply:

    3 * 33,554,432 = 100,663,296
    [L] 21 * 1,048,576 = 22,020,096
    [N] 23 * 32,768 = 753,664
    [J] 19 * 1024 = 19,456
    8 * 32 = 256
    [L] 21 * 1 = 21
    ---------------

    If my math was correct and there are no typos then the above should add up to 123,456,789. (I have no idea how the text formatting is going to turn out when I hit "Submit Reply". I didn't know how to do it.)

    Is that helpful at all?

    Edit: The text formatting didn't turn out exactly like I wanted it, but it still isn't too bad.
    Last edited by nicknameoscar; 05-31-2011 at 05:46 PM. Reason: commenting about how format turned out

  9. #9
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by nicknameoscar View Post
    Is that helpful at all?
    actually, it's probably not. I think this person needs a small function for conversion. If you could turn what you just wrote into an actual vba function it would be more relevant.

  10. #10
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    Quote Originally Posted by ajetrumpet View Post
    actually, it's probably not. I think this person needs a small function for conversion. If you could turn what you just wrote into an actual vba function it would be more relevant.
    I doubt I am good enough yet to turn out a function like that without considerable effort.

    To be totally honest, I had never dealt with anything other than binary, octal or hex and I just wanted to see if I could figure out how Base 32 worked.

    I will take a look at designing a function when I am not so tired. It sounds like a fun challenge .

  11. #11
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    well this is actually NOT tough.

    first of all, you have to figure out what you want as the end result. for instance, does the end result change or not?? E.G. -

    111 base 32 does NOT equal 111 base 10

    so if you want to keep your RESULT value the same in terms of it's actual number value, all you need to do is perform the drawn out calculations we've already done. BASE 10 is nothing more than the number itself after the base 32 calculations are performed.

    so for instance, to convert a BASE 32 number to BASE 10 in vba, all you need is this:

    Code:
    Function to10(base32 As String)
    
    Dim base As Long
    Dim length As Long
    Dim pos As Long
    Dim temp As Long
    
        base = Len(base32) - 1
        length = Len(base32)
        pos = 1
    
            While base >= 0
                temp = temp + (CLng(Mid(base32, pos, 1)) * (32 ^ (base)))
                base = base - 1
                pos = pos + 1
            Wend
    
    to10 = temp
    
    End Function
    hence, my example of 200 checks out fine. the answer is 2048.

    200 BASE 32 = 2048 BASE 10 with the above function, and with my previous post. Again, the fact that base 10 numbers are their actual values was the thing that was missed here I think. It's not difficult to convert to BASE 10. The difficult part would be converting from 32 to something other than 10. That would require much more code.

  12. #12
    brandonze is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Mar 2011
    Posts
    49
    Thanks everybody for the feedback. I think the VBA that was given will work fine for my use. thanks again

  13. #13
    brandonze is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Mar 2011
    Posts
    49
    ajetrumpet,

    I installed your function and keep getting an error. When I go to the error the line temp = temp + (CLng(Mid(base32, pos, 1)) * (32 ^ (base)))
    Is highlighted.

    I put the function in a new moduale and am using the function in an unbound text box. however, It wont run. Am I doing something wrong?

  14. #14
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    PMFJI,

    I installed your function and keep getting an error. When I go to the error the line temp = temp + (CLng(Mid(base32, pos, 1)) * (32 ^ (base)))
    Is highlighted.
    The problem here is that for any base greater than 10 (decimal), the position in the number is represented by a letter. The letter must be converted to a decimal number; ie in hexadecimal, "10" (decimal) is represented by the letter "A" (hex).

    I modified the code ajetrumpet provided. To call the function you would use:

    = toDec("3LNJ8L", 32) 'the letters are case insensitive

    Code:
    Function toDec(pNumber As String, pBase As Integer) As Double
    
       Dim base As Long
       Dim length As Long
       Dim pos As Long
       Dim temp As Long
       Dim MyValue  'varient - to hold letters
       Dim tmp As Long
       Dim MaxLetter As Integer
       Dim i As Integer
    
       toDec = 0
       base = Len(pNumber) - 1
       length = Len(pNumber)
       pos = 1
    
       ' is pNumber within base range
       MaxLetter = pBase - 1
       For i = 1 To length
          If Asc(Mid(pNumber, i, 1)) - 55 > MaxLetter Then
             MsgBox "'" & pNumber & "' is not a base" & pBase & " number"
             Exit Function
          End If
       Next
    
    
       While base >= 0
          MyValue = Mid(pNumber, pos, 1)
    
          '                                    A = ascii 65 and Z = ascii 90
          'convert letter to value
          If Asc(UCase(MyValue)) >= 65 And Asc(UCase(MyValue)) <= 90 Then
             tmp = CLng(Asc(UCase(MyValue)) - 55)
          Else
             tmp = CLng(MyValue)
          End If
          temp = temp + (tmp * (pBase ^ (base)))
          base = base - 1
          pos = pos + 1
       Wend
    
       toDec = temp
    
    End Function
    This should be able to convert up to base 35 (uses letters A-Z)

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Sharing a data base
    By Cran29 in forum Security
    Replies: 3
    Last Post: 02-05-2011, 06:45 PM
  2. Base-34 class or alternetives
    By is49460 in forum Programming
    Replies: 3
    Last Post: 06-29-2010, 07:59 PM
  3. Data base design
    By mduplantis in forum Database Design
    Replies: 1
    Last Post: 06-05-2010, 07:30 PM
  4. Same Form, different base query
    By Goodge12 in forum Forms
    Replies: 3
    Last Post: 01-22-2010, 11:29 PM
  5. Having trouble with dates in my Data Base!!!!
    By BigPhil in forum Queries
    Replies: 4
    Last Post: 02-15-2006, 12:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums