Question Make an encoder

islanderon

New member
Joined
Oct 24, 2010
Messages
3
Programming Experience
Beginner
I want to make an encoder that puts the alphabet backwards like so:

abcdefghijklmnopqrstuvwxyz
zyxwvutsrqponmlkjihgfedcba

so that the letter on the top encodes to the letter on the bottom.
I don't know if this is possible but any response will be very helpful.
If I need to be more exact just tell me.

THANK YOU!!!
 
There are various options, but they all basically rely on determining how far from the beginning of a list of letters the current letter, then finding the letter that is as far from the end of the same list and replacing.

The easy way would be to just put all the letters into a String. You can then use String.IndexOf to find the index of a character. Subtract that index from the Length of the String and subtract 1 more to get the index of the character to replace it with, then index the String to get that character. You can loop through the characters in the original String and add the replacements to a new String as you go.
 
Do you mean

Dim String As String
string.indexof

then what?

can you put it into code I understand things much better when it is in code.

THANK YOU!!!!
 
You're the one writing the application. You are the one who should write the code. I see lots of people say things like:
I understand things much better when it is in code.
but what that really means is that it's easier for them not to think and have someone else write the code for them than for them to make the effort for themselves. You actually understand things much better when you do them for yourself. It might be more difficult and take longer, but you learn more in the end and that is my main concern. I'm very happy to help you fix issues you may have along the way but I won't be writing the code for you. When I see you making an effort I can give you hints and advice on how to fix the code you have written but writing the code for yourself will do more to make you a better developer.
 
Ok I got some but I need a hint

I used the following code:

Dim ABCDEFGHIJKLMNOPQRSTUVWXYZ As String
ABCDEFGHIJKLMNOPQRSTUVWXYZ= "A""B""C""D""E""F""G""H""I""J""K""L""M""N""O""P""Q""R""S""T""U""V""W""X""Y""Z"

and then I wrote a bunch of lines like the following

ABCDEFGHIJKLMNOPQRSTUVWXYZ.IndexOf("A" = "Z")

Am I doing it right?

if so how to I use it to convert text.

If I'm not doing It right please explain better
 
First up, you wouldn't use a variable name like that because it's pointlessly long. You would call it 'alphabet' or 'letters' or 'characters' or something like that. Those names are shorter and actually more descriptive.

Secondly, the way you have broken up the letters isn't valid. There's no need to break them up anyway. All you need is one String. That String has an IndexOf method and it can be treated pretty much as though it's an array of characters, i.e. it has a length property and you can get a single character by index. How do you usually write a string literal? It's a bunch of characters with a double quote at each end, right?

Finally, please explain what you're doing here:
VB.NET:
ABCDEFGHIJKLMNOPQRSTUVWXYZ.IndexOf("A" = "Z")
You wrote that for a reason, so what do you think it's doing? Have you done any research on how to use String.IndexOf, e.g. have you looked up the MSDN documentation for it? There's lots you can do to find information for yourself. There's tons of it out there so sensible searches will find lots of what you need. The documentation is also the first place you should look when you already know what type and/or member you need to use.
 
Back
Top