Posts: 1
Threads: 1
Joined: May 2003
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.
Posts: 1,439
Threads: 15
Joined: Apr 2003
s$ = "abcdefg"
s$ = ucase$(s$)
for i = 1 to len(s$)
print asc(mid$(s$, i, 1)) - asc("A");
next i
Posts: 720
Threads: 46
Joined: Oct 2001
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)
Posts: 1,439
Threads: 15
Joined: Apr 2003
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.
Posts: 2,765
Threads: 138
Joined: Nov 2002
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
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Posts: 2,020
Threads: 24
Joined: Jun 2002
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
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Posts: 1,439
Threads: 15
Joined: Apr 2003
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: