By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,089 Members | 1,952 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,089 IT Pros & Developers. It's quick & easy.

Creating an "Encoder/Decoder" in VB

P: 16
Basically my friend's parents used to log his AIM and email so we made a barbaric version of an encoder that we could type in what we wanted and get random letters out. The only problem is that I did it in Truebasic, and I am new to VB. I have the interface layed out with an Encode button and a Decode button with an Input and an output/log. Eventually I want to have it just with universal hotkeys to where you can highlight a text and it automatically either unscrambles it and puts it in the log as incoming or you highlight what you type and press the hotkey and it automatically scrambles and sends it. I have the ActiveX for the hotkeys and such but I cant get the program working correctly without them first! Here is a screen of the interface.



This is the code I have written so far for it under the Encode button, obviously once I have that running I just flip the arrays for the decode so there is no point in me posting the whole thing. I will spre you all the 26 lines of me setting up the alphabet arrays because I cant figure out how to do a read/data in VB so it's 26 lines.

sl = Len(uinput.Text)
For x = 1 To sl
word2$(x) = Mid$(uinput, x, 1)
Next x
For x = 1 To sl
Print word2$(x); 'test to see if running so far
Next x
m = 0
Do Until w = sl
w = w + 1
For x = 1 To 26
If alpha$(x) = word2$(w) Then r = x
Next x
Log.Text = code$(r)
Loop



So basically it is supposed to break down the input into the array word2$. alpha$ is an array of the alphabet (1-26) and code$ is an array of random letters of the alphabet to produce the scramble. Now when I run this i get the print of whatever I'm putting in, but I get NO output into my "log" or output box. Now I'm pretty sure the way I have it set up it would only give me the last letter of my input in the box even if it did work, but I'm not even getting that.

HELP please??
Nov 22 '06 #1
Share this Question
Share on Google+
2 Replies


100+
P: 267
Basically my friend's parents used to log his AIM and email so we made a barbaric version of an encoder that we could type in what we wanted and get random letters out. The only problem is that I did it in Truebasic, and I am new to VB. I have the interface layed out with an Encode button and a Decode button with an Input and an output/log. Eventually I want to have it just with universal hotkeys to where you can highlight a text and it automatically either unscrambles it and puts it in the log as incoming or you highlight what you type and press the hotkey and it automatically scrambles and sends it. I have the ActiveX for the hotkeys and such but I cant get the program working correctly without them first! Here is a screen of the interface.



This is the code I have written so far for it under the Encode button, obviously once I have that running I just flip the arrays for the decode so there is no point in me posting the whole thing. I will spre you all the 26 lines of me setting up the alphabet arrays because I cant figure out how to do a read/data in VB so it's 26 lines.

sl = Len(uinput.Text)
For x = 1 To sl
word2$(x) = Mid$(uinput, x, 1)
Next x
For x = 1 To sl
Print word2$(x); 'test to see if running so far
Next x
m = 0
Do Until w = sl
w = w + 1
For x = 1 To 26
If alpha$(x) = word2$(w) Then r = x
Next x
Log.Text = code$(r)
Loop



So basically it is supposed to break down the input into the array word2$. alpha$ is an array of the alphabet (1-26) and code$ is an array of random letters of the alphabet to produce the scramble. Now when I run this i get the print of whatever I'm putting in, but I get NO output into my "log" or output box. Now I'm pretty sure the way I have it set up it would only give me the last letter of my input in the box even if it did work, but I'm not even getting that.

HELP please??
hi

try this link

Alab

if you want the source, send me a mail
Nov 22 '06 #2

Expert 5K+
P: 8,434
...Now I'm pretty sure the way I have it set up it would only give me the last letter of my input in the box even if it did work, but I'm not even getting that.
I haven't had time to go over the code thoroughly, but wher eyou have this
Expand|Select|Wrap|Line Numbers
  1. Log.Text = code$(r)
You can concatenate the text by using
Expand|Select|Wrap|Line Numbers
  1. Log.Text = Log.Text & code$(r)
Also, I'd suggest you look into functions such as Chr( ) and Asc( ) which should allow you to reduce your code somewhat by converting things more directly. For example, rather than looping through up to 26 array entries to find the number corresponding to a letter, you could use something like Asc(word$(x)) - 64 (the uppercase letters start at 65 in ASCII).
Nov 22 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.