Click here to Skip to main content
15,887,214 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionVB6 Int() Function Pin
Marcus J. Smith10-May-07 5:05
professionalMarcus J. Smith10-May-07 5:05 
AnswerRe: VB6 Int() Function Pin
Dave Kreskowiak10-May-07 5:17
mveDave Kreskowiak10-May-07 5:17 
GeneralRe: VB6 Int() Function [modified] Pin
Marcus J. Smith10-May-07 5:26
professionalMarcus J. Smith10-May-07 5:26 
GeneralRe: VB6 Int() Function Pin
Dave Kreskowiak10-May-07 6:28
mveDave Kreskowiak10-May-07 6:28 
GeneralRe: VB6 Int() Function Pin
Marcus J. Smith10-May-07 6:38
professionalMarcus J. Smith10-May-07 6:38 
AnswerRe: VB6 Int() Function Pin
Guffa10-May-07 8:18
Guffa10-May-07 8:18 
GeneralRe: VB6 Int() Function Pin
Marcus J. Smith10-May-07 8:28
professionalMarcus J. Smith10-May-07 8:28 
QuestionCaesar Cipher Crack Pin
Irshadt10-May-07 3:27
Irshadt10-May-07 3:27 
I used the following code to crack Caesar Cipher code where the key is unknown. I have written the following code and is it not working. I want it done in access. Plz Plz help me.

Option Compare Database
Option Base 1

Private Sub Command4_Click()
Dim naturalDist(26, 2) As Double

naturalDist(1, 1) = 1
naturalDist(2, 1) = 2
naturalDist(3, 1) = 3
naturalDist(4, 1) = 4
naturalDist(5, 1) = 5
naturalDist(6, 1) = 6
naturalDist(7, 1) = 7
naturalDist(8, 1) = 8
naturalDist(9, 1) = 9
naturalDist(10, 1) = 10
naturalDist(11, 1) = 11
naturalDist(12, 1) = 12
naturalDist(13, 1) = 13
naturalDist(14, 1) = 14
naturalDist(15, 1) = 15
naturalDist(16, 1) = 16
naturalDist(17, 1) = 17
naturalDist(18, 1) = 18
naturalDist(19, 1) = 19
naturalDist(20, 1) = 20
naturalDist(21, 1) = 21
naturalDist(22, 1) = 22
naturalDist(23, 1) = 23
naturalDist(24, 1) = 24
naturalDist(25, 1) = 25
naturalDist(26, 1) = 26

naturalDist(1, 2) = 0.08167
naturalDist(2, 2) = 0.01492
naturalDist(3, 2) = 0.02782
naturalDist(4, 2) = 0.04253
naturalDist(5, 2) = 0.12702
naturalDist(6, 2) = 0.02228
naturalDist(7, 2) = 0.02015
naturalDist(8, 2) = 0.06094
naturalDist(9, 2) = 0.06966
naturalDist(10, 2) = 0.00153
naturalDist(11, 2) = 0.00772
naturalDist(12, 2) = 0.04025
naturalDist(13, 2) = 0.02406
naturalDist(14, 2) = 0.06749
naturalDist(15, 2) = 0.07507
naturalDist(16, 2) = 0.01929
naturalDist(17, 2) = 0.00095
naturalDist(18, 2) = 0.05987
naturalDist(19, 2) = 0.06327
naturalDist(20, 2) = 0.09056
naturalDist(21, 2) = 0.02758
naturalDist(22, 2) = 0.00978
naturalDist(23, 2) = 0.0236
naturalDist(24, 2) = 0.0015
naturalDist(25, 2) = 0.01974
naturalDist(26, 2) = 0.00074


Dim theText As String
Dim resultText As String
Dim i As Integer
Dim j As Integer

Form_Form4.Text0.SetFocus
theText = Form_Form4.Text0.Text
theText = Replace(theText, " ", "")
theText = Replace(theText, ",", "")
theText = Replace(theText, ".", "")
theText = Replace(theText, ";", "")
theText = Replace(theText, "'", "")
theText = Replace(theText, """", "")
theText = Replace(theText, "-", "")
theText = Replace(theText, ":", "")
theText = Replace(theText, "%", "")
theText = Replace(theText, "*", "")
theText = Replace(theText, "$", "")
theText = Replace(theText, "!", "")
theText = Replace(theText, "@", "")
theText = Replace(theText, "#", "")
theText = Replace(theText, "(", "")
theText = Replace(theText, ")", "")
theText = Replace(theText, "_", "")
theText = Replace(theText, "+", "")
theText = Replace(theText, "/", "")
theText = Replace(theText, "\", "")
theText = Replace(theText, "|", "")
theText = Replace(theText, "?", "")
theText = Replace(theText, Chr(10), "")
theText = UCase(theText)

Dim theCharDist(26, 2) As Double
For i = 1 To (Len(theText))
theCharDist(Asc(Mid(theText, i, 1)) - Asc("A") + 1, 2) = theCharDist(Asc(Mid(theText, i, 1)) - Asc("A") + 1, 2) + 1
Next i

For i = 1 To 26
theCharDist(i, 1) = i
If theCharDist(i, 2) = 0 Then
theCharDist(i, 2) = theCharDist(i, 2) / Len(theText)
Else
theCharDist(i, 2) = 1
End If
Next i

For i = 1 To 26
For j = i To 25
If theCharDist(j, 2) > theCharDist(j + 1, 2) Then
Dim tmp(2) As Double

tmp(1) = theCharDist(j, 1)
tmp(2) = theCharDist(j, 2)

theCharDist(j, 1) = theCharDist(j + 1, 1)
theCharDist(j, 2) = theCharDist(j + 1, 2)

theCharDist(j + 1, 1) = tmp(1)
theCharDist(j + 1, 2) = tmp(2)
End If
Next j
Next i

For i = 1 To 26
For j = i To 25
If naturalDist(j, 2) > naturalDist(j + 1, 2) Then
Dim tmp2(2) As Double

tmp2(1) = naturalDist(j, 1)
tmp2(2) = naturalDist(j, 2)

naturalDist(j, 1) = naturalDist(j + 1, 1)
naturalDist(j, 2) = naturalDist(j + 1, 2)

naturalDist(j + 1, 1) = tmp2(1)
naturalDist(j + 1, 2) = tmp2(2)
End If
Next j
Next i

Dim lookupTab(26, 2) As Integer
For i = 1 To 26
For j = 1 To 26
If naturalDist(j, 1) = i Then
lookupTab(i, 1) = j
End If

If theCharDist(j, 1) = i Then
lookupTab(i, 2) = j
End If
Next j
Next i


For i = 1 To (Len(theText))
resultText = resultText + Chr(Asc("A") + naturalDist(lookupTab(Asc(Mid(theText, i, 1)) - Asc("A") + 1, 2), 1))
Next i

Form_Form4.Text2.SetFocus
Form_Form4.Text2 = resultText
End Sub

Private Sub Command7_Click()
Form_Form4.Text8.SetFocus
FN$ = Form_Form4.Text8.Text

LoadTextBox FN$, Form_Form4.Text0
End Sub

AnswerRe: Caesar Cipher Crack Pin
Colin Angus Mackay10-May-07 3:29
Colin Angus Mackay10-May-07 3:29 
QuestionCaesar Cipher Crack Pin
Irshadt10-May-07 3:24
Irshadt10-May-07 3:24 
AnswerRe: Caesar Cipher Crack Pin
Colin Angus Mackay10-May-07 3:30
Colin Angus Mackay10-May-07 3:30 
GeneralRe: Caesar Cipher Crack Pin
Christian Graus10-May-07 10:29
protectorChristian Graus10-May-07 10:29 
QuestionRe: Regular Expression Pin
ant1xxx10-May-07 1:55
ant1xxx10-May-07 1:55 
AnswerRe: Regular Expression Pin
Christian Graus10-May-07 2:14
protectorChristian Graus10-May-07 2:14 
QuestionPassing custom object to web service Pin
BobsAfro10-May-07 1:15
BobsAfro10-May-07 1:15 
AnswerRe: Passing custom object to web service Pin
nlarson1110-May-07 4:05
nlarson1110-May-07 4:05 
GeneralRe: Passing custom object to web service Pin
BobsAfro10-May-07 5:42
BobsAfro10-May-07 5:42 
GeneralRe: Passing custom object to web service Pin
nlarson1110-May-07 5:48
nlarson1110-May-07 5:48 
GeneralRe: Passing custom object to web service Pin
nlarson1110-May-07 5:52
nlarson1110-May-07 5:52 
GeneralRe: Passing custom object to web service Pin
BobsAfro10-May-07 5:54
BobsAfro10-May-07 5:54 
GeneralRe: Passing custom object to web service Pin
nlarson1110-May-07 5:59
nlarson1110-May-07 5:59 
GeneralRe: Passing custom object to web service Pin
BobsAfro10-May-07 6:21
BobsAfro10-May-07 6:21 
GeneralRe: Passing custom object to web service Pin
nlarson1110-May-07 6:29
nlarson1110-May-07 6:29 
GeneralRe: Passing custom object to web service Pin
BobsAfro10-May-07 6:29
BobsAfro10-May-07 6:29 
GeneralRe: Passing custom object to web service Pin
Dave Kreskowiak10-May-07 6:34
mveDave Kreskowiak10-May-07 6:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.