converting numbers to letters

T

Treebeard

I'd like to write a function that converts a integer, to the coressponding
letter in the alphabet?


i.e.

ConvertToLetter(1) ' this would return "A"
ConvertToLetter(2) ' this would return "B"
ConvertToLetter(3) ' this would return "C"
ConvertToLetter(4) ' this would return "D"


Thanks,

Jack
 
M

martin

x being your number this does it 'Chr(x + 64)'. It does no
error checking.

martin
 
Q

quixote

There is probably an easier way to do this but this works.

Public Function ConvertToLetter(inputValue)
Select Case inputValue
Case 1
ConvertToLetter = "A"

Case 2
ConvertToLetter = "B"

Case 3
ConvertToLetter = "C"

Case 4
ConvertToLetter = "D"

Case 5
ConvertToLetter = "E"

Case 6
ConvertToLetter = "F"

'.........

Case 26
ConvertToLetter = "Z"

Case Else
ConvertToLetter = "No Letter"



End Select

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top