Contoh Program Kalkuklator dengan Visual basic
Contoh
Program:
1. Desain program
2. Pengaturan Properties
|
NO.
|
OBJEK
|
PROPERTIES
|
PENGATURAN
|
|
1
|
Label1
|
Text
|
OPERASI MATEMATIKA
|
|
|
|
Font Size
|
9
|
|
|
|
Bold
|
True
|
|
2
|
Label2
|
Text
|
Bilangan 1 :
|
|
3
|
Label3
|
Text
|
Bilangan 2 :
|
|
4
|
Label4
|
Text
|
Hasil :
|
|
5
|
Label5
|
Text
|
OPERATOR
|
|
|
|
Bold
|
True
|
|
6
|
TextBox1
|
Name
|
txtbil1
|
|
7
|
TextBox2
|
Name
|
txtbil2
|
|
8
|
TextBox3
|
Name
|
Txthasil
|
|
9
|
Button1
|
Text
|
^
|
|
|
|
Size
|
10
|
|
|
|
Name
|
Btnpangkat
|
|
10
|
Button2
|
Text
|
*
|
|
|
|
Size
|
10
|
|
|
|
Name
|
Btnkali
|
|
11
|
Button3
|
Text
|
/
|
|
|
|
Name
|
Btnbagi
|
|
12
|
Button4
|
Text
|
+
|
|
|
|
Size
|
9
|
|
|
|
Name
|
Btntambah
|
|
13
|
Button5
|
Text
|
-
|
|
|
|
Size
|
10
|
|
|
|
Name
|
Btnkurang
|
|
14
|
Button6
|
Text
|
Bersih
|
|
|
|
Name
|
Btnbersih
|
|
15
|
Button7
|
Text
|
Tutup
|
|
|
|
Name
|
Btntutup
|
3. Pemberian Perintah/Instruksi pada Program
Alur
Program:
ú Input Bilangan1 dan Bilangan2
ú Klik salah satu tombol Operator, maka akan tampil hasil perhitungan
sesuai operator.
-
Tombol ^ : untuk
memangkatkan
-
Tombol * : untuk
mengalikan
-
Tombol / : untuk
membagi
-
Tombol + : untuk
menambahkan
-
Tombol - : untuk
mengurangkan
ú Klik tombol Bersih, maka isi Bilangan1, Bilangan2 dan
Hasil akan bersih (kosong).
ú Klik tombol Tutup, maka program akan ditutup.
Perintah Program:
Private Sub btnpangkat_Click(ByVal
sender As System.Object,
txthasil.Text = txtbil1.Text ^
txtbil2.Text
End Sub
Private Sub btnkali_Click(ByVal
sender As System.Object,
txthasil.Text = txtbil1.Text *
txtbil2.Text
End Sub
Private Sub btnbagi_Click(ByVal
sender As System.Object,
txthasil.Text = txtbil1.Text /
txtbil2.Text
End Sub
Private Sub btntambah_Click(ByVal
sender As System.Object,
txthasil.Text = Val(txtbil1.Text) +
txtbil2.Text
End Sub
Private Sub btnkurang_Click(ByVal
sender As System.Object,
txthasil.Text = txtbil1.Text -
txtbil2.Text
End Sub
Catatan:
Val : berfungsi untuk
mengubah tipe data string menjadi Numeric.

Comments
Post a Comment