Posted by : HD Technology Studio
Kamis, 16 Februari 2017
Kali ini admin akan share mengenai pembuatan aplikasi perpangkatan dengan VB.Net. Jadi logikanya adalah seperti ini :
- User memasukkan angka yang ingin dipangkat kan pada TextBox
- User memilih pangkat pada ComboBox
- User menghitung dengan menekan tombol submit
- Hasil akan ditampilkan pada RichTextBox
- Jika selesai user menekan tombol Ok
- Buat project baru pada vb.net dengan nama AplikasiPerpangkatan atau sesuai keinginian anda.
- Desain aplikasi seperti gambar diatas. Adapun tool yang dibutuhkan ialah 1 buah ComboBox, 1 buah RichTextbox, 2 buah Button, 2 buah Label.
- Ubah masing – masing properties nya seperti tabel dibawah :
- Masuk code editor dengan cara klik view ( code atau shortcut dengan menekan F7.
- Definisikan variabel, disini admin menggunakan variabel global. Masih bingung perbedaan variabel global dan variabel lokal dan bagaimana menuliskan variabel pada vb.net, silahkan baca postingan saya tentang Variabel pada VB.Net.
- Tipe data yang admin gunakan adalah double dan byte. Mengapa demikian, karena variabel angka nanti juga akan admin gunakan sebagai hasil dari perhitungan sehingga diperlukan jangkauan yang lebih luas. Baca postingan mengenai Tipe data pada VB.Net.
- Selanjutnya kembali ke design, klik dua kali pada button Ok. Dan masukkan kode di bawah ini yang berfungsi untuk membersihkan TextBox maupun RichTextBox serta memfokuskan RichButton1.
- Kembali ke design. Klik 2 kali btnsubmit, kemudian masukkan kode berikut :
- Selanjutnya kita akan berikan event pada RichButton. RichButton ini berfungsi untuk menentukan pangkat. Logikanya, seandainya kita memilih RichButton1 maka bilangan yang ada pada TextBox akan dipangkatkan dengan 1, begitu juga dengan 2, 3, 4 dan seterusnya. Atau bisa juga berfungsi untuk memanggil fungsi operation pada btnsubmit. Klik pada rbbuton1, kemudian masukkan kode :
- Berikut kode lengkapnya secara keseluruhan :
- Jalankan aplikasinya, jika tidak ada error, maka aplikasi telah berhasil dibuat.
- Berikut merupakan aplikasi yang telah berhasil dibuat.
Komponen | Properties | Nilai |
Form1 | Name | Form1 |
Text | Aplikasi Perpangkatan | |
StartPosition | CenterScreen | |
GroupBox1 | Text | Pangkat |
RichButton1 | Name | rbbutton1 |
Text | 1 | |
RichButton2 | Name | rbbutton2 |
Text | 2 | |
RichButton3 | Name | rbbutton3 |
Text | 3 | |
RichButton4 | Name | rbbutton4 |
Text | 4 | |
RichButton5 | Name | rbbutton5 |
Text | 5 | |
RichButton6 | Name | rbbutton6 |
Text | 6 | |
RichButton7 | Name | rbbutton7 |
Text | 7 | |
RichButton8 | Name | rbbutton8 |
Text | 8 | |
RichButton9 | Name | rbbutton9 |
Text | 9 | |
RichButton10 | Name | rbbutton10 |
Text | 10 | |
RichButton11 | Name | rbbutton11 |
Text | 11 | |
RichButton12 | Name | rbbutton12 |
Text | 12 | |
RichButton13 | Name | rbbutton13 |
Text | 13 | |
RichButton14 | Name | rbbutton14 |
Text | 14 | |
Label1 | Text | Enter Here |
Label2 | Text | Result |
Button1 | Name | btnsubmit |
Text | Submit | |
Button2 | Name | btnok |
Text | Ok | |
TextBox1 | Name | txtenter |
RichBox1 | Name | rtresult |
ReadOnly | True |
Public angka As Double
Public operation As Byte
txtenter.Text = ""
rtresult.Text = ""
rb1.Focus()
If operation = "1" Then
angka = Double.Parse(txtenter.Text) ^ 1
rtresult.Text = angka
ElseIf operation = "2" Then
angka = Double.Parse(txtenter.Text) ^ 2
rtresult.Text = angka
ElseIf operation = "3" Then
angka = Double.Parse(txtenter.Text) ^ 3
rtresult.Text = angka
ElseIf operation = "4" Then
angka = Double.Parse(txtenter.Text) ^ 4
rtresult.Text = angka
ElseIf operation = "5" Then
angka = Double.Parse(txtenter.Text) ^ 5
rtresult.Text = angka
ElseIf operation = "6" Then
angka = Double.Parse(txtenter.Text) ^ 6
rtresult.Text = angka
ElseIf operation = "7" Then
angka = Double.Parse(txtenter.Text) ^ 7
rtresult.Text = angka
ElseIf operation = "8" Then
angka = Double.Parse(txtenter.Text) ^ 8
rtresult.Text = angka
ElseIf operation = "9" Then
angka = Double.Parse(txtenter.Text) ^ 9
rtresult.Text = angka
ElseIf operation = "10" Then
angka = Double.Parse(txtenter.Text) ^ 10
rtresult.Text = angka
ElseIf operation = "11" Then
angka = Double.Parse(txtenter.Text) ^ 11
rtresult.Text = angka
ElseIf operation = "12" Then
angka = Double.Parse(txtenter.Text) ^ 12
rtresult.Text = angka
ElseIf operation = "13" Then
angka = Double.Parse(txtenter.Text) ^ 13
rtresult.Text = angka
ElseIf operation = "14" Then
angka = Double.Parse(txtenter.Text) ^ 14
rtresult.Text = angka
End If
angka = Double.Parse(txtenter.Text) ^ 1
rtresult.Text = angka
ElseIf operation = "2" Then
angka = Double.Parse(txtenter.Text) ^ 2
rtresult.Text = angka
ElseIf operation = "3" Then
angka = Double.Parse(txtenter.Text) ^ 3
rtresult.Text = angka
ElseIf operation = "4" Then
angka = Double.Parse(txtenter.Text) ^ 4
rtresult.Text = angka
ElseIf operation = "5" Then
angka = Double.Parse(txtenter.Text) ^ 5
rtresult.Text = angka
ElseIf operation = "6" Then
angka = Double.Parse(txtenter.Text) ^ 6
rtresult.Text = angka
ElseIf operation = "7" Then
angka = Double.Parse(txtenter.Text) ^ 7
rtresult.Text = angka
ElseIf operation = "8" Then
angka = Double.Parse(txtenter.Text) ^ 8
rtresult.Text = angka
ElseIf operation = "9" Then
angka = Double.Parse(txtenter.Text) ^ 9
rtresult.Text = angka
ElseIf operation = "10" Then
angka = Double.Parse(txtenter.Text) ^ 10
rtresult.Text = angka
ElseIf operation = "11" Then
angka = Double.Parse(txtenter.Text) ^ 11
rtresult.Text = angka
ElseIf operation = "12" Then
angka = Double.Parse(txtenter.Text) ^ 12
rtresult.Text = angka
ElseIf operation = "13" Then
angka = Double.Parse(txtenter.Text) ^ 13
rtresult.Text = angka
ElseIf operation = "14" Then
angka = Double.Parse(txtenter.Text) ^ 14
rtresult.Text = angka
End If
Operation = "1"
Klik rbbutton2, kemudian masukkan kode
Operation = "2"
Begitu juga dengan rbbuton3, cukup diubah angkanya saja.
Operation = "3"
Dan seterusnya sampai dengan rbbuton14.
Public Class Form1
' Deklarasi Variabel
Public angka As Double
Public operation As Byte
Private Sub btnok_Click(sender As Object, e As EventArgs) Handles btnok.Click
txtenter.Text = ""
rtresult.Text = ""
rb1.Focus()
End Sub
'Deklarasi btnsubmit dengan menggunakan pernyataan if...then dengan kondisi jamak
Private Sub btnsubmit_Click(sender As Object, e As EventArgs) Handles btnsubmit.Click
If operation = "1" Then
angka = Double.Parse(txtenter.Text) ^ 1
rtresult.Text = angka
ElseIf operation = "2" Then
angka = Double.Parse(txtenter.Text) ^ 2
rtresult.Text = angka
ElseIf operation = "3" Then
angka = Double.Parse(txtenter.Text) ^ 3
rtresult.Text = angka
ElseIf operation = "4" Then
angka = Double.Parse(txtenter.Text) ^ 4
rtresult.Text = angka
ElseIf operation = "5" Then
angka = Double.Parse(txtenter.Text) ^ 5
rtresult.Text = angka
ElseIf operation = "6" Then
angka = Double.Parse(txtenter.Text) ^ 6
rtresult.Text = angka
ElseIf operation = "7" Then
angka = Double.Parse(txtenter.Text) ^ 7
rtresult.Text = angka
ElseIf operation = "8" Then
angka = Double.Parse(txtenter.Text) ^ 8
rtresult.Text = angka
ElseIf operation = "9" Then
angka = Double.Parse(txtenter.Text) ^ 9
rtresult.Text = angka
ElseIf operation = "10" Then
angka = Double.Parse(txtenter.Text) ^ 10
rtresult.Text = angka
ElseIf operation = "11" Then
angka = Double.Parse(txtenter.Text) ^ 11
rtresult.Text = angka
ElseIf operation = "12" Then
angka = Double.Parse(txtenter.Text) ^ 12
rtresult.Text = angka
ElseIf operation = "13" Then
angka = Double.Parse(txtenter.Text) ^ 13
rtresult.Text = angka
ElseIf operation = "14"
Then angka = Double.Parse(txtenter.Text) ^ 14
rtresult.Text = angka
End If
End Sub
' Deklarasi radio button
Private Sub rb10_Click(sender As Object, e As EventArgs) Handles rb10.Click
operation = "10"
End Sub
Private Sub rb11_Click(sender As Object, e As EventArgs) Handles rb11.Click
operation = "11"
End Sub
Private Sub rb12_Click(sender As Object, e As EventArgs) Handles rb12.Click
operation = "12"
End Sub
Private Sub rb13_Click(sender As Object, e As EventArgs) Handles rb13.Click
operation = "13"
End Sub
Private Sub rb14_Click(sender As Object, e As EventArgs) Handles rb14.Click
operation = "14"
End Sub
Private Sub rb1_Click(sender As Object, e As EventArgs) Handles rb1.Click
operation = "1"
End Sub
Private Sub rb2_Click(sender As Object, e As EventArgs) Handles rb2.Click
operation = "2"
End Sub
Private Sub rb3_Click(sender As Object, e As EventArgs) Handles rb3.Click
operation = "3"
End Sub
Private Sub rb4_Click(sender As Object, e As EventArgs) Handles rb4.Click
operation = "4"
End Sub
Private Sub rb5_Click(sender As Object, e As EventArgs) Handles rb5.Click
operation = "5"
End Sub
Private Sub rb6_Click(sender As Object, e As EventArgs) Handles rb6.Click
operation = "6"
End Sub
Private Sub rb7_Click(sender As Object, e As EventArgs) Handles rb7.Click
operation = "7"
End Sub
Private Sub rb8_Click(sender As Object, e As EventArgs) Handles rb8.Click
operation = "8"
End Sub
Private Sub rb9_Click(sender As Object, e As EventArgs) Handles rb9.Click
operation = "9"
End Sub
End Class
' Deklarasi Variabel
Public angka As Double
Public operation As Byte
Private Sub btnok_Click(sender As Object, e As EventArgs) Handles btnok.Click
txtenter.Text = ""
rtresult.Text = ""
rb1.Focus()
End Sub
'Deklarasi btnsubmit dengan menggunakan pernyataan if...then dengan kondisi jamak
Private Sub btnsubmit_Click(sender As Object, e As EventArgs) Handles btnsubmit.Click
If operation = "1" Then
angka = Double.Parse(txtenter.Text) ^ 1
rtresult.Text = angka
ElseIf operation = "2" Then
angka = Double.Parse(txtenter.Text) ^ 2
rtresult.Text = angka
ElseIf operation = "3" Then
angka = Double.Parse(txtenter.Text) ^ 3
rtresult.Text = angka
ElseIf operation = "4" Then
angka = Double.Parse(txtenter.Text) ^ 4
rtresult.Text = angka
ElseIf operation = "5" Then
angka = Double.Parse(txtenter.Text) ^ 5
rtresult.Text = angka
ElseIf operation = "6" Then
angka = Double.Parse(txtenter.Text) ^ 6
rtresult.Text = angka
ElseIf operation = "7" Then
angka = Double.Parse(txtenter.Text) ^ 7
rtresult.Text = angka
ElseIf operation = "8" Then
angka = Double.Parse(txtenter.Text) ^ 8
rtresult.Text = angka
ElseIf operation = "9" Then
angka = Double.Parse(txtenter.Text) ^ 9
rtresult.Text = angka
ElseIf operation = "10" Then
angka = Double.Parse(txtenter.Text) ^ 10
rtresult.Text = angka
ElseIf operation = "11" Then
angka = Double.Parse(txtenter.Text) ^ 11
rtresult.Text = angka
ElseIf operation = "12" Then
angka = Double.Parse(txtenter.Text) ^ 12
rtresult.Text = angka
ElseIf operation = "13" Then
angka = Double.Parse(txtenter.Text) ^ 13
rtresult.Text = angka
ElseIf operation = "14"
Then angka = Double.Parse(txtenter.Text) ^ 14
rtresult.Text = angka
End If
End Sub
' Deklarasi radio button
Private Sub rb10_Click(sender As Object, e As EventArgs) Handles rb10.Click
operation = "10"
End Sub
Private Sub rb11_Click(sender As Object, e As EventArgs) Handles rb11.Click
operation = "11"
End Sub
Private Sub rb12_Click(sender As Object, e As EventArgs) Handles rb12.Click
operation = "12"
End Sub
Private Sub rb13_Click(sender As Object, e As EventArgs) Handles rb13.Click
operation = "13"
End Sub
Private Sub rb14_Click(sender As Object, e As EventArgs) Handles rb14.Click
operation = "14"
End Sub
Private Sub rb1_Click(sender As Object, e As EventArgs) Handles rb1.Click
operation = "1"
End Sub
Private Sub rb2_Click(sender As Object, e As EventArgs) Handles rb2.Click
operation = "2"
End Sub
Private Sub rb3_Click(sender As Object, e As EventArgs) Handles rb3.Click
operation = "3"
End Sub
Private Sub rb4_Click(sender As Object, e As EventArgs) Handles rb4.Click
operation = "4"
End Sub
Private Sub rb5_Click(sender As Object, e As EventArgs) Handles rb5.Click
operation = "5"
End Sub
Private Sub rb6_Click(sender As Object, e As EventArgs) Handles rb6.Click
operation = "6"
End Sub
Private Sub rb7_Click(sender As Object, e As EventArgs) Handles rb7.Click
operation = "7"
End Sub
Private Sub rb8_Click(sender As Object, e As EventArgs) Handles rb8.Click
operation = "8"
End Sub
Private Sub rb9_Click(sender As Object, e As EventArgs) Handles rb9.Click
operation = "9"
End Sub
End Class
Download Source Code Aplikasi perpangkatan dengan VB.Net di Sini
Atau baca Via Academia.edu
Related Posts :
- Back to Home »
- source code , Tutorial , Tutorial Vb.Net , vb.net »
- Membuat aplikasi Perpangkatan dengan VB.Net