Hello. I'm stuck on a problem for a class I'm taking and wondering if anybody could help me. The user enters an alphabetic phone number (ABC-DEFG) and then the program is supposed to convert it to its numeric values (222-3334). I've tried everything I could think of, with MID$, LEFT$, and ASC but nothing seems to be working. Any help would be appreciated.
s$ = "abcdefg"
s$ = ucase$(s$)
for i = 1 to len(s$)
print asc(mid$(s$, i, 1)) - asc("A");
next i
Quote:s$ = "abcdefg"
s$ = ucase$(s$)
for i = 1 to len(s$)
print asc(mid$(s$, i, 1)) - asc("A");
next i
Almost, except that there's several numbers on each key... let the man figure how to do that himself, tho.
(worst case scenario, you could always just use a CASE statement)
hehe... my mistake. But yeah, I think it says in the FAQ that when posting homework problems, one should show that one has at least attempted the problem.
I made one and it is BIG
It uses a lot of IF statements.
:wink:
But it works!
You input:
1-800-CALL-SAM
and it outputs:
1-800-2255-726
If statements arent necessary with smart programming.
HINT:
Code:
dim alphabet as string
for x = 2 to 9
read append$
alphabet = alphabet + append$
next x
DATA "222", "333", "444", "555", "666", "7777", "888", "9999"
but way to go on the effort, i would never have that kind of patience
or you could do this:
Code:
s$ = "abcdefg"
s$ = ucase$(s$)
for i = 1 to len(s$)
print asc(mid$(s$, i, 1)) / 3 - asc("A") + 1;
next i
oh wait... that doesn't work for the keys with 4 letters... nevermind. :oops: