PDA

View Full Version : help! i need a good soultion to a project i just got in school



razlevav
12-09-2013, 03:37 AM
hey
we've been asked to do the next thing:
you know that we have on our old phones letters under the numbers 2-9
so they want us to do the next thing
by entring a number between 3-6 digits, the excel will show me all the virous combnation of letters their is.
like if i enter 842 it will show me tgb and ugc and tia and vib and so on...
anyone got an idea what i can do?

SamT
12-09-2013, 10:44 AM
School homework?

Loop thru the digits
For i = 1 to Len(NumberString)

Extract each digit

X = Mid(NumberString, i, 1)

Perform a Select Case on X and


OutPut = CaseResult & ", " & CaseResult

Loop again
Next i

Note that you can substitute the assignment for X in the Select Case

razlevav
12-09-2013, 04:33 PM
sorry english is not my first langue. im a ba student and its for a advenced excel course. i'm in college.

i don't think i understand your soultion



School homework?

Loop thru the digits
For i = 1 to Len(NumberString)

Extract each digit

X = Mid(NumberString, i, 1)

Perform a Select Case on X and


OutPut = CaseResult & ", " & CaseResult

Loop again
Next i

Note that you can substitute the assignment for X in the Select Case

EirikDaude
12-09-2013, 08:40 PM
I think he made a rough outline of what approach you could use, and then left it to you figuring out the details, considering it's homework and all :P

SamT
12-09-2013, 09:58 PM
It is not a solution. We don't solve homework problems. It is an algorithm (https://en.wikipedia.org/wiki/Algorithm).

We will guide you (like above) and help you find and understand errors in your own code.

In my first post code, NumberString and CaseOutput are made up words.

All the other words are real VBA functions. Type them into the VBA code editor, leave the cursor in or next to a word, and press F1 for help on that word.

I suggest that you copy your code and paste it into a reply here. After you paste it, select all the code and press the # icon on the editor. This will format the code and place it in a box for easy viewing. Alternatively, you can press the # icon and paste the code between the code tags.

Then we will help you correct any errors and help you develop your code into a working system.

Since the Select Case function is the solution to replacing digits with three letter Strings, I offered no help on it.

The other issue with your assignment is displaying the resuls of the code. You should develop that algorithm after you have the basic number to letters code working. For now, just use the example I used so you can test that code. Hint: Put a Watch on CaseResult.

GTO
12-15-2013, 09:26 PM
Greetings razlevav,

Are you still working on this? I ask as I found it interesting, due to the dissimilar sized letter groups.

Mark