Hallo, disini saya akan share sedikit tentang cara
menghitung volume balok dan luas segitiga pada program visual basic 2010, walaupun tidak
terlalu bagus tapi lumayanlah buat belajar., heee….
Okee…
Tanpa basa basi
lagi kita lansung ke langkah-langkahnya,
Terlebih dahulu buka start
menu,
kemudian pilih program visual
basic 2010.
Lalu, new project
Kemudian pilih mindows
form Application, disini juga terdapat location yaitu untuk
mengatur dimana tempat anda menyimpan file, kemudian OK.
Setelah di OK akan muncul tampilan
seperti di bawah ini (form 1).
Lalu buat tampilan seperti di
bawah ini, menggunakan 7 Textbox,
7 Label
, 2 Groupbox, 5 Button, kemudian atur posisinya
seperti di gambar.
Groupbox kiri untuk luas segitiga
dan yang kanan untuk volume balok.
Untuk merubah nama sesuai yang ingin kita buat maka double klik di dalam
form
1,Terus buat kodingan seperti dibawahi ini,
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "Alas"
Label2.Text = "Tinggi"
Label3.Text = "Hasil"
Label4.Text = "Panjang"
Label5.Text = "Lebar"
Label6.Text = "Tinggi"
Label7.Text = "Hasil"
Button1.Text = "Proses"
Button2.Text = "Hapus"
Button3.Text = "Proses"
Button4.Text = "Hapus"
Button5.Text = "Quit"
GroupBox1.Text = "Luas Segi Tiga"
GroupBox2.Text = "Volume balok"
End Sub
Setelah itu double klik di Button
untuk memberikan perintah (koding) agar bias di jalankan, begitu juga
berikkutnya, disini kita bermain sedikit logika.
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox3.Text = (1 / 2) * Val(TextBox1.Text) * Val(TextBox2.Text)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "Alas"
Label2.Text = "Tinggi"
Label3.Text = "Hasil"
Label4.Text = "Panjang"
Label5.Text = "Lebar"
Label6.Text = "Tinggi"
Label7.Text = "Hasil"
Button1.Text = "Proses"
Button2.Text = "Hapus"
Button3.Text = "Proses"
Button4.Text = "Hapus"
Button5.Text = "Quit"
GroupBox1.Text = "Luas Segi Tiga"
GroupBox2.Text = "Volume balok"
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Close()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox7.Text = Val(TextBox4.Text) * Val(TextBox5.Text) * Val(TextBox6.Text)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox3.Text = (1 / 2) * Val(TextBox1.Text) * Val(TextBox2.Text)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "Alas"
Label2.Text = "Tinggi"
Label3.Text = "Hasil"
Label4.Text = "Panjang"
Label5.Text = "Lebar"
Label6.Text = "Tinggi"
Label7.Text = "Hasil"
Button1.Text = "Proses"
Button2.Text = "Hapus"
Button3.Text = "Proses"
Button4.Text = "Hapus"
Button5.Text = "Quit"
GroupBox1.Text = "Luas Segi Tiga"
GroupBox2.Text = "Volume balok"
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Close()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
TextBox7.Text = Val(TextBox4.Text) * Val(TextBox5.Text) * Val(TextBox6.Text)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
End Sub
End Class
Jika semua sudah , coba klik run (jalankan)
atau F5. Jika berhasil akan muncul tampilan seperti ini,,
Jika sudah muncul coba masukkan
angka dan tekan tombol Proses, kemudian coba tombol Hapus,
setelah itu Quit.
Jika semua sudah OK/bisa
dijalankn, selamat deh…. Yang belum, coba lagi ya,,,, upayakan agar lebih
teliti lagi,,, hheeeeeeeeeeee
OKhanya itu dari saya,,,
Tanks,,
Tidak ada komentar:
Posting Komentar