Sesuai dengan aparan pak
mesran untuk mengerjakan tugas akhir semester, dengan membuat penggabungan beberapa program dalam satu menu utama maka saya akan membuat langkah langkahnya
1. buatlah form kerja baru dengan cara
file>new project>add
2. Tambahkan 4 form lagi untuk masing masing Kriptografi,dengan cara
project>add windows form>ok
lakukan langkah kedua hingga sampai form 5
3. Desainlah setiap form sesuai dengan gambar dibawah ini
untuk membuat tampilan seperti diatas pertama kitaharus menambahkan MenuStrip pada toolbox lalu isi menu apa saja yg kita inginkan
contoh : File,Keluar
Selanjutnya pada Properties gantilah IsMdiContainer menjadi True
4. buatlan sub menu pada "file",ini berfungsi sebagai media perantara saat pemanggilan form lain
contoh ; Kriptografi Caesar,Kriptografi Vernam,Kriptografi gransfeld,Kriptografi viginere
5. berikut ini adalah coding untuk pemanggilan form formnya
cara memasukkan codingnya dengan cara mengklik 2x setiap sub menu lalu isikan kodingnya seperti dibawah ini
form 2
Private Sub KriptografiCaesarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiCaesarToolStripMenuItem.Click
Form2.MdiParent = Me
Form2.Show()
End Sub
form 3
Private Sub KriptografiVernamToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiVernamToolStripMenuItem.Click
Form3.MdiParent = Me
Form3.Show()
End Sub
form 4
Private Sub KriptografiGronsfledToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiGronsfledToolStripMenuItem.Click
Form4.MdiParent = Me
Form4.Show()
End Sub
form 5
Private Sub KriptografiVigenereToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KriptografiVigenereToolStripMenuItem.Click
Form5.MdiParent = Me
Form5.Show()
End Sub
Private Sub KeluarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KeluarToolStripMenuItem.Click
End
End Sub
End Class
lakukan pengetesan terlebih dahulu ,apakah pemanggilan setiap form telah sesuai ,jika telah sesuai maka kita bisa melanjutkan kelangkah berikutnya
6. Desainlah form form tadi seperti program yang telah saya posting sebelumnya
A. Form 2
Public Class Form2
Private Sub btnenskipsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenskipsi.Click
Dim x As String = ""
Dim xkalimat As String = ""
For i = 1 To Len(plain.Text)
x = Mid(plain.Text, i, 1)
x = Chr(Asc(x) + 3)
xkalimat = xkalimat + x
Next
chiper.Text = xkalimat
End Sub
Private Sub btndeskripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndeskripsi.Click
Dim x As String = ""
Dim xkalimat As String = ""
For i = 1 To Len(chiper.Text)
x = Mid(chiper.Text, i, i)
x = Chr(Asc(x) - 3)
xkalimat = xkalimat + x
Next
plain.Text = xkalimat
End Sub
Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
plain.Text = ""
End Sub
End Class
B. Form 3
Public Class Form3
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
plainteks.Text = ""
kunci.Text = ""
chiperteks.Text = ""
End Sub
Private Sub btnenkripsi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnenkripsi.Click
Dim j As Integer
Dim jum As Integer
Dim sKey As String
Dim nKata As Integer
Dim nKunci As Integer
Dim sKata As String
Dim sPlain As String = ""
Dim nEnc As Integer
j = 0
sKata = plainteks.Text
jum = Len(sKata)
sKey = kunci.Text
For i = 1 To jum
If j = Len(sKey) Then
j = 1
Else
j = j + 1
End If
nKata = Asc(Mid(sKata, 1, 1)) - 65
nKunci = Asc(Mid(sKey, j, 1)) - 65
nEnc = ((nKata + nKunci) Mod 26)
sPlain = sPlain & Chr((nEnc) + 65)
Next i
chiperteks.Text = sPlain
End Sub
Private Sub plainteks_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles plainteks.KeyPress
e.KeyChar = UCase(e.KeyChar)
Dim tombol As Integer = Asc(e.KeyChar)
If Not ((tombol >= 65) And (tombol <= 90)) Or (tombol = 8) Then
e.Handled = True
End If
End Sub
Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
plainteks.Text = ""
kunci.Text = ""
chiperteks.Text = ""
End Sub
End Class
C. Form 4
Public Class Form4
Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
input.Text = ""
hasil.Text = ""
End Sub
Private Sub btnhitung_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhitung.Click
Dim ind As Integer
Dim huruf, kalimat As String
Dim jumlah(25) As Integer
kalimat = (input.Text).ToUpper
For x = 1 To Microsoft.VisualBasic.Len(kalimat)
huruf = kalimat.Substring(x - 1, 1)
If (huruf >= "A") And (huruf <= "Z") Then
ind = Asc(huruf) - 65
jumlah(ind) += 1
End If
Next
hasil.Text = ""
For i As Integer = 0 To 25
huruf = Chr(i + 65)
If jumlah(i) > 0 Then
hasil.Text = hasil.Text & huruf & " = " & jumlah(i) & vbCrLf
End If
Next
End Sub
Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
input.Text = ""
hasil.Text = ""
End Sub
End Class
D. Form 5
Public Class Form5
Private Sub btnproses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnproses.Click
chipertekx.Text = Enkripsi(plainteks.Text, Kunci.Text)
End Sub
Function Enkripsi(ByVal Teks As String, ByVal Kunci As String) As String
Dim j As Integer
Dim jum As Integer
Dim sKey As String
Dim nKata As Integer
Dim nKunci As Integer
Dim sKata As String
Dim sPlain As String
Dim nEnc As Integer
j = 0
jum = Len(Teks)
sPlain = ""
sKey = Kunci
sKata = Teks
For i = 1 To jum
If j = Len(sKey) Then
j = 1
Else
j = j + 1
End If
nKata = Asc(Mid(sKata, i, 1))
nKunci = Asc(Mid(sKey, j, 1))
nEnc = ((nKata + nKunci) Mod 256)
sPlain = sPlain & Chr((nEnc))
Next i
Enkripsi = sPlain
End Function
Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click
plainteks.Text = ""
chipertekx.Text = ""
kunc.Text = ""
End Sub
End Class
7.jika telah selesai semuanya maka cobalah jalankan Program tersebut jika berhasil maka tampilannya akan seperti ini
Demikianlah postongan tutorial saya ,jangan lupa kunjungi
blog saya dan juga
website pak mesran yang berisikan semua tentang program mulai dari php,c++,pacsal,delphi,vb dan banyak lagi