aaronk Well-Known Member Licensed User Longtime User Jun 27, 2014 #1 Hi, I am trying to convert a number into a Letter. It might sound simple but I just can't work this simple thing out. What I am trying to do is the Number 1 should convert to A and 17 should be B etc, up to 256. For Example: 1-16 = A 17-32 = B .. .. 97-112 = G .. .. 241-256 = P Anyone able to help ?
Hi, I am trying to convert a number into a Letter. It might sound simple but I just can't work this simple thing out. What I am trying to do is the Number 1 should convert to A and 17 should be B etc, up to 256. For Example: 1-16 = A 17-32 = B .. .. 97-112 = G .. .. 241-256 = P Anyone able to help ?
eps Expert Licensed User Longtime User Jun 27, 2014 #2 If then else if? Although I'm sure there's a more clever way to do this. I was going to say a Case statement, but that might be harder to do and a bit clumsy. Regex? http://www.b4x.com/android/forum/threads/regex-and-replace.15677/#post-138823 Upvote 0
If then else if? Although I'm sure there's a more clever way to do this. I was going to say a Case statement, but that might be harder to do and a bit clumsy. Regex? http://www.b4x.com/android/forum/threads/regex-and-replace.15677/#post-138823
NJDude Expert Licensed User Longtime User Jun 27, 2014 #3 You could create a small database with 3 fields: Min, Max and Letter and then just query it and get the corresponding letter depending on the value. Upvote 0
You could create a small database with 3 fields: Min, Max and Letter and then just query it and get the corresponding letter depending on the value.
nwhitfield Active Member Licensed User Longtime User Jun 27, 2014 #4 Subtract one from your number. Divide it (as an Int) by 16. So for 1-16, the result will be 0. For 17-32 it will be 1. Add 65 to your answer, and you'll have the ASCII code of the letter you want. Eg B4X: Dim mynum as int log(chr((mynum-1)/16)+65) Upvote 0
Subtract one from your number. Divide it (as an Int) by 16. So for 1-16, the result will be 0. For 17-32 it will be 1. Add 65 to your answer, and you'll have the ASCII code of the letter you want. Eg B4X: Dim mynum as int log(chr((mynum-1)/16)+65)