web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to convert int to count of alphabet?

(0) ShareShare
ReportReport
Posted on by 350

Hello, everyone!

I have to make the following function.

count = 1 -> alphabet count = A

count = 2 -> alphabet count = B

count = 3 -> alphabet count = C

count = 4 -> alphabet count = D

.

.

.

count = 50 -> alphabet count = AX

count = 51 -> alphabet count = AY

.

.

How can I make the function?

Or, does the function already exist?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Jonathan  Halland Profile Picture
    11,310 on at

    Hi

    I'm not sure of the point of what you are trying to do at all, but if you want to convert a single number to a letter you could use num2char([yournum]+64)

    This would assume your letters are already all capitals and you're using standard ASCII. There is no logic I can see that would make 50 = AX and 51 = AY. If you have your own logic you could use an ENUM in AX to define that A = 1... AX = 50 and then use enum functions to convert back and forward.

  • Verified answer
    dongwoon Profile Picture
    350 on at

    Thank you, Jonathan.

    I solved the problem myself.

    public str int2Alphabet(int dividend)

       {            

           str columnName;

           int modulo;

           while (dividend > 0)

           {

               modulo = (dividend - 1) mod 26;

               columnName = num2char(65 + modulo) + columnName;

               dividend = (dividend - modulo) / 26;

           }

           return columnName;

       }

  • JII SAADUDDIN Profile Picture
    1,832 on at

    Did you mean strLen() or num2char(), or strKeep() ?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans