5 Replies - 2255 Views - Last Post: 05 December 2009 - 12:12 PM

#1 iwantthependrive   User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 15-February 09

Letter substitution code

Posted 25 April 2009 - 07:32 AM

Description: make 2 command buttons and a text box.substitutes a letter with another letter based on a passkey.
'THIS ENCODES THE LETTER
Private Sub Command1_Click()
Dim pa As Long, a As String, b As Long, i As Long, c As String, num As Long
If Text1.Text = "" Then
MsgBox "There is Nothing To Encrypt"
Else
pa = InputBox("Enter passkey (only between 1 and 128")
a = Text1.Text
Text1.Text = ""
b = Len(a)
For i = 1 To b
c = Mid(a, i, 1)
num = Asc(c)
num = num + pa
If num > 256 Then
MsgBox "Lower Passkey!"
End If
Text1.Text = Text1.Text + Chr(num)
Next i
qwe = MsgBox("Your Passkey is " & pa, vbInformation)
End If
End Sub

'THIS DECODES THE LETTER
Private Sub Command1_Click()
Dim pa As Long, a As String, b As Long, i As Long, c As String, num As Long
If Text1.Text = "" Then
MsgBox "There is Nothing To Decrypt"
Else
pa = InputBox("Enter Your Passkey")
a = Text1.Text
Text1.Text = ""
b = Len(a)
For i = 1 To b
c = Mid(a, i, 1)
num = Asc(c)
num = num - pa
If pa > 128 Then
MsgBox "Passkey should be between 1 and 128!"
End If
cl = Chr(num)
Text1.Text = Text1.Text + cl
Next i
End If
End Sub




Is This A Good Question/Topic? 0
  • +

Replies To: Letter substitution code

#2 iwantthependrive   User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 15-February 09

Re: Letter substitution code

Posted 25 April 2009 - 07:32 AM

Description: make 2 command buttons and a text box.substitutes a letter with another letter based on a passkey.
'THIS ENCODES THE LETTER
Private Sub Command1_Click()
Dim pa As Long, a As String, b As Long, i As Long, c As String, num As Long
If Text1.Text = "" Then
MsgBox "There is Nothing To Encrypt"
Else
pa = InputBox("Enter passkey (only between 1 and 128")
a = Text1.Text
Text1.Text = ""
b = Len(a)
For i = 1 To b
c = Mid(a, i, 1)
num = Asc(c)
num = num + pa
If num > 256 Then
MsgBox "Lower Passkey!"
End If
Text1.Text = Text1.Text + Chr(num)
Next i
qwe = MsgBox("Your Passkey is " & pa, vbInformation)
End If
End Sub

'THIS DECODES THE LETTER
Private Sub Command2_Click()
Dim pa As Long, a As String, b As Long, i As Long, c As String, num As Long
If Text1.Text = "" Then
MsgBox "There is Nothing To Decrypt"
Else
pa = InputBox("Enter Your Passkey")
a = Text1.Text
Text1.Text = ""
b = Len(a)
For i = 1 To b
c = Mid(a, i, 1)
num = Asc(c)
num = num - pa
If pa > 128 Then
MsgBox "Passkey should be between 1 and 128!"
End If
cl = Chr(num)
Text1.Text = Text1.Text + cl
Next i
End If
End Sub



Was This Post Helpful? 0
  • +
  • -

#3 iwantthependrive   User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 15-February 09

Re: Letter substitution code

Posted 25 April 2009 - 07:32 AM

Description: make 2 command buttons and a text box.substitutes a letter with another letter based on a passkey.
'THIS ENCODES THE LETTER
Private Sub Command1_Click()
Dim pa As Long, a As String, b As Long, i As Long, c As String, num As Long
If Text1.Text = "" Then
MsgBox "There is Nothing To Encrypt"
Else
pa = InputBox("Enter passkey (only between 1 and 128")
a = Text1.Text
Text1.Text = ""
b = Len(a)
For i = 1 To b
c = Mid(a, i, 1)
num = Asc(c)
num = num + pa
If num > 256 Then
MsgBox "Lower Passkey!"
End If
Text1.Text = Text1.Text + Chr(num)
Next i
MsgBox "Your Passkey is " & pa, vbInformation
End If
End Sub

'THIS DECODES THE LETTER
Private Sub Command2_Click()
Dim pa As Long, a As String, b As Long, i As Long, c As String, num As Long, cl as string
If Text1.Text = "" Then
MsgBox "There is Nothing To Decrypt"
Else
pa = InputBox("Enter Your Passkey")
a = Text1.Text
Text1.Text = ""
b = Len(a)
For i = 1 To b
c = Mid(a, i, 1)
num = Asc(c)
num = num - pa
If pa > 128 Then
MsgBox "Passkey should be between 1 and 128!"
End If
cl = Chr(num)
Text1.Text = Text1.Text + cl
Next i
End If
End Sub



Was This Post Helpful? 0
  • +
  • -

#4 firebolt   User is offline

  • D.I.C Lover
  • member icon

Reputation: 93
  • View blog
  • Posts: 5,561
  • Joined: 20-February 09

Re: Letter substitution code

Posted 28 April 2009 - 05:30 AM

If you say make 2 command buttons, wouldnt you want the second to be command2.
Was This Post Helpful? 0
  • +
  • -

#5 iwantthependrive   User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 15-February 09

Re: Letter substitution code

Posted 02 May 2009 - 07:19 AM

i am sorry. i have corrected it.
Was This Post Helpful? 0
  • +
  • -

#6 hbhargava   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 30
  • Joined: 07-August 09

Re: Letter substitution code

Posted 28 August 2009 - 10:49 AM

in vb 2008 it tells me that cl is not declared, and same with qwe
Was This Post Helpful? 0
  • +
  • -

#7 iwantthependrive   User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 15-February 09

Re: Letter substitution code

Posted 30 August 2009 - 07:03 AM

i have modified it. it should work now.
Was This Post Helpful? 0
  • +
  • -

#8 borninlyoko   User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 350
  • Joined: 03-December 09

Re: Letter substitution code

Posted 05 December 2009 - 12:12 PM

I'm getting an error, line 3 character 8. It says it expected end of statement
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1