Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7668797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:26:54+00:00 2026-05-31T15:26:54+00:00

I’m looking for a decimal to alphanumeric number base converter library in Visual Basic

  • 0

I’m looking for a decimal to alphanumeric number base converter library in Visual Basic that does not use recursion.

I found:
http://visualstudiomagazine.com/articles/2010/07/20/when-hexadecimal-is-not-enough.aspx

which includes a demo app but discovered that it uses recursion. The problem with it using recursion became apparent when I attempted to integrate the library into my own Visual Studio Express 2010 Visual Basic project: I got a stack overflow exception.

Now I could consider increasing the size memory allocated for the stack but it might be hard to determine what this would be, given that the recursion depth might vary depending on the value to be converted.

My situation requires a reliable deterministic solution so I would prefer to discount the idea of using recursion.

I shall do more research and endeavour to write the algorithm from scratch but would rather not re-invent the wheel if it already exists so hence this question. A search on here did not quite give me what I was looking for.

Can you point me in the direction of an existing non-recursive decimal to alphanumeric converter library in Visual Basic?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:26:55+00:00Added an answer on May 31, 2026 at 3:26 pm

    This solution I provide myself appears to work – so simple too! But that’s because it is a one-way conversion; the other libraries aim to be two-way conversion, back and forth between difference bases – but I don’t need both ways.

    
    Public Class BaseConverter
    
    
        Public Shared Function ConvertToBase(num As Integer, nbase As Integer) As String
    
            Dim retval = ""
    
            Dim chars As String = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    
            ' check if we can convert to another base
            If (nbase  chars.Length) Then
                retval = ""
            End If
    
            Dim r As Integer
    
            Dim newNumber As String = ""
    
            ' in r we have the offset of the char that was converted to the new base
            While num >= nbase
                r = num Mod nbase
                newNumber = chars(r) & newNumber
    
                'use: num = Convert.ToInt32(num / nbase)
                '(if available on your system)
                'otherwise:
                num = num \ nbase
                ' notice the back slash \ - this is integer division, i.e the calculation only reports back the whole number of times that
                ' the divider will go into the number to be divided, e.g. 7 \ 2 produces 3 (contrasted with 7 / 2 produces 3.5, 
                ' float which would cause the compiler to fail the compile with a type mismatch)
            End While
    
            ' the last number to convert
            newNumber = chars(num) & newNumber
    
            Return newNumber
        End Function
    
    
    End Class
    
    

    I created the above code in Visual Basic based on the C# code in the following link:

    CREDIT: http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/5babf71f-4375-40aa-971a-21c1f0b9762b/
    (“convert from decimal(base-10) to alphanumeric(base-36)”)

    
    public String ConvertToBase(int num, int nbase)
    {
        String chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    
        // check if we can convert to another base
        if(nbase  chars.Length)
            return "";
    
        int r;
        String newNumber = "";
    
        // in r we have the offset of the char that was converted to the new base
        while(num >= nbase)
        {
            r = num % nbase;
            newNumber = chars[r] + newNumber;
            num = num / nbase;
        }
        // the last number to convert
        newNumber = chars[num] + newNumber;
    
        return newNumber;
    }
    

    @assylias I couldn’t get devx.com/vb2themax/Tip/19316 to work – I got the wrong value back. Thanks though for the suggestion.

    There is no evidence that it works. I adjusted some declarations and superficial structure of the code to get it to build successfully in Visual Studio Express 2010 Visual Basic. Then stepped through the code in the Visual Studio Express 2010 Visual Basic debugger, the code is hard to follow: variable names not obvious, no comments as to why it is doing what it is doing. From what I understood it was doing, it did not seem like it should be doing that to do the base conversion.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.