Untuk pembelajaran awal, saya membuat kalkulator sederhana menggunakan visual studio 2012 ultimate
, yang gampang di pelajari oleh para nuwbi, hehehehe , ga usah banyak basa basi
lasung ajah :
1. Buka Visual Studio 2010 Express for Windows
Phone. Pada "start page" pilih "New Project". Atau pada
menu "File" --> New Project :
2. Akan muncul window, seperti di bawah ini :
Keterangan
gambar :
1. Pilih windows
2. Pilih windows Form Application
3.Beri nama
Project
4.Pillih folder penyimpanan
5.Selesai
3.Buat tampilan Form seperti gambar di baawah ini
:
Jenis
|
Nama
|
text
|
Lable 1
|
Label 1
|
Kalkulator sederhana
|
Lable 2
|
Label 2
|
Bilangan 1
|
Lable 3
|
Label 3
|
Bilangan 2
|
Lable 4
|
Label 4
|
Hasil
|
TextBox 1
|
Bilangan 1
|
(kosong)
|
TextBox 2
|
Bilangan 2
|
(kosong)
|
TextBox 3
|
Hasil
|
(kosong)
|
Button 1
|
Tambah
|
+
|
Button 2
|
Kurang
|
-
|
Button 3
|
Kali
|
*
|
Button 4
|
Bagi
|
/
|
Button 5
|
Brsh
|
Bersihkan
|
Nutton 6
|
Klr
|
Keluar
|
4. Masukan kode” seperti berikut :
Public Class Form1
Dim bil1
As Single
Dim bil2
As Single
Dim Hasile
As Single
Private
Sub Tamnbah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Tambah.Click
bil1 =
Val(Bilangan1.Text)
bil2 =
Val(Bilangan2.Text)
Hasile
= bil1 + bil2
Hasil.Text = Str(Hasile)
End Sub
Private
Sub Kurang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Kurang.Click
bil1 =
Val(Bilangan1.Text)
bil2 =
Val(Bilangan2.Text)
Hasile
= bil1 - bil2
Hasil.Text = Str(Hasile)
End Sub
Private
Sub Kali_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Kali.Click
bil1 =
Val(Bilangan1.Text)
bil2 =
Val(Bilangan2.Text)
Hasile
= bil1 * bil2
Hasil.Text = Str(Hasile)
End Sub
Private
Sub klr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles klr.Click
If
MsgBox("Apakh anda yakin ", vbYesNo + vbQuestion + vbDefaultButton2,
"Keluar") = vbYes Then
Me.Close()
End If
End Sub
Private
Sub brsh_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles brsh.Click
Bilangan1.Clear()
Bilangan2.Clear()
Hasil.ResetText()
Bilangan1.Focus()
End Sub
Private
Sub Bagi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Bagi.Click
bil1 =
Val(Bilangan1.Text)
bil2 =
Val(Bilangan2.Text)
Hasile
= bil1 / bil2
Hasil.Text = Str(Hasile)
End Sub
End Class
5. Hasil akan seperti gambar berikut :
unduh : http://www.ziddu.com/download/20683201/WindowsApplication11.rar.html