Ok I need to find out how to do an if statement that finds one letter in a word. then I need to know how to add that letter to a textbox with out earsing the text all ready in the box. please help with code.
Printable View
Ok I need to find out how to do an if statement that finds one letter in a word. then I need to know how to add that letter to a textbox with out earsing the text all ready in the box. please help with code.
You need to get a letter from a word and add it to a textbox?
Code:'this is a really simple example
Private Sub Command1_Click() 'add a commandbutton
Dim pos%, Mystr$
'If you need to find all occurances of one character place this in a loop... post if you need help with that
Mystr = "I am Jop!"
pos = Instr(1, Mystr, "o")
Text1.Text = Text1.Text & Mid(Mystr, pos, 1) 'add to text leaving all other characters intact, and only get one character.
End Sub
I need to get the letter from a differnt text box.
it's for an encryption part of a program. I want it to take the word in textbox change each letter (like a=c and stuff like that) and put the new word in anouther text box. I should have said that in the first place sorry.
Ouch, that'll be a real weak encryption then :(
Check keda's site for a cool encryption algorithm (www.kedaman.com)
Anyway, if you really want to do that (copying each letter)
Have fun but I recommend a better algorythmCode:Private Sub BadEncrypt(txtU As String, txtE As TextBox)
dim tmp$
For x = 0 To Len(txtU)
tmp = Mid(txtU, x, 1)
'Do whatever you want with the character here!
'Ie:
'If Lcase(tmp) = "a" Then tmp = "c"
'but it's better to use a Select Case statement
txtE.Text = txtE.Text & tmp
Next x
End Sub
'Call it like
Private Sub Command1_Click() 'in a commandbutton
BadEncrypt(Text1.Text, Text2.Text)
End Sub
I know it's a weak encryption, but i don't plan to have peole trying to hack into my program.
Oh ok, did it help?
How about using the Internet shopping method?
To encode the password do like that every "a" in it will be "45382" in the encryption and every "b" in the password will be "76433" and so on...
When the app decodes it every "45382" will be "a", every "76433" will be "b" and so on...
It will be hard but it will be a kickass encryption!
By the way, it's not just for you, anyone here can use my little method!
Nice, isn't it?
But you have to make sure that when it comes out in encoding "4538276433" so the app won't think that "d" will be "82764" but you can bypass that by making the app go through 5 characters at a time. I know it has something to do with "Mid" function.
Hope you can get any help for this coz I have no idea of doing this!
Yes it helped Jop THanks!!!!! And thanks for the idea Asaf_99.
Here's a cool encryption program I got from someone (wish I could remember who...)
To try it out, paste the code into the form's code window. Put 3 text boxes and 2 command buttons on the form (keep the default names). Type some text into the first text box. Press command button 1 to Encrypt the text and display it in text box 2. Press command button 2 to Decrypt the text in text box 2 and display it in text box 3.
Not the most secure, but it works well.
Code:Option Explicit
Public Function Encrypt(ByVal theText As String) As String
Dim i, i1 As Integer
Dim letter, s1, code1, a, finstr As String
For i = 1 To Len(theText)
letter = Mid(theText, i, 1)
a = Asc(letter)
a = (3 * a) - 1
If a < 10 Then
a = "0" & a
End If
If a < 100 Then
a = "0" & a
End If
finstr = finstr & a
Next i
code1 = finstr
For i1 = 1 To Len(code1)
s1 = s1 & Chr(Int(Mid(code1, i1, 1)) + 117)
Next i1
Encrypt = s1
End Function
Public Function DeCrypt(ByVal Text As String) As String
Dim code, s1, letter, lcode, finstr As String
Dim i, curi As Integer
Dim LLcode As Long
code = Text
For i = 1 To Len(code)
s1 = s1 & Asc(Mid(code, i, 1)) - 117
Next i
code = s1
For i = 1 To Int(Len(code) / 3)
curi = i * 3 - 2
lcode = Mid(code, curi, 3)
LLcode = Val(Int(lcode))
LLcode = (LLcode + 1) / 3
finstr = finstr & Chr(LLcode)
Next i
DeCrypt = finstr
End Function
Private Sub Command1_Click()
Text2 = Encrypt(Text1)
End Sub
Private Sub Command2_Click()
Text3 = DeCrypt(Text2)
End Sub
I know a friend of mine who has come up with an encription method that would take around 2billion years to crack with a supper computer it uses the same methods as the enigma in WW2 but alot of it has bin improved like the fact he uses 16 incription weels and the weels can move places as well Owch!
Asaf_99 that's a nice nice idea however won't the number pattern give away how the encryption is working. I mean for example the letter E occures the most right well a hacker can then work out which code occures the most, the second most, the thired most etc and he is able to code a dycription program.
Try adding some funcky mad ass maths in it?
this should through him/her off a bit or even a key to code each char by, this sarts to really add depth to the encryption and makes it that more stonger.
Thats what the weels are for so no two charictors are the same, like e = & in one part and e = h in another thats why it's so hard to crack one of the extras that was put in was the fact that e could = e so you could thow them off more.. hehe :)
Yeah well, a math thing can be cool, like every letter will be added. Like in the encoding part "a" is 29653 and "b" is 67473 and when you encode it you will have a+b=97126 you will break it apart.
However, how will the hacker see the incoded password? he doesn't see it and only the pc itself will. Nothing can take a look of a string (or any other variable) which is in another program which not built to "serve" any other running application.
You don'tsend the key with the message this is how it works...
Message --> Encript with key:"Blah"
Encripted Message without key --> send to reader
ReaderEncripts Message with Key:"halB"
Double Encripted message gets sent back to
creator the creator then decripts the message with "Blah"
then the decripted-encripted message is sent back to
the reader the reader decripts eith the key:"halB" and hey
presto a readable message, nether of the keys were sent
and the message than travles would take billions of years to decript haha lets see our hackers get past that!
DoctorMO how would the double encrypted message be decoded if the top encryption is covering the underlaying one?
Doesn't the top encrytion need to be removed first?
:rolleyes:
Here's a cool (short) blurb on Public key encryption from Webopeadia:
http://webopedia.internet.com/TERM/p...ptography.html
I have known about that incription method but have never tryed to use it in VB were as the one above I have used as a feature in an e-mail program.