Sekarang Mau kasih tutorial Pemrograman Visual Mengunakan
VB.Net, Aplikasi pembuatan kalkulator mungkin banyak sumber di google yang
mengajarkan tutorial pembuatan kalkulator,
semoga bisa menambah referensi
saudara.
Dari Tampilan diatas diperlukan komponen-komponen sebagai berikut
19 Button, Dan 1 TextBox. Untuk membuat software Kalkulator ini, pertama Pilih
FILE > New Project > Windows Forms Application dan pada kolom name beri
nama Kalkulator.
Kemudian setelah Form1 muncul atur di properties pilih text
ganti nama dengan Kalkulator
- Tambahkan Komponen-komponen yang dibutuhkan kedalam form anda bisa menyusun sesuka hati. Atau mengikuti contoh diatas.
- Double Klik Formnya kemudian akan terbuka seperti ini
- Tambahkan code dibawah Public Class kalkulator
Public Class Form1
Dim Operand1 As Double
Dim Operand2 As Double
Dim [Operator] As String
- Kemudian arahkan pada button 1
Atur Properties
Locked
|
True
|
Text
|
1
|
Double Click
Button1 dan masukan code di bawah ini
Private Sub Button1_Click(ByVal sender As
System.Object, ByVal
e As System.EventArgs)
Handles Button1.Click, Button2.Click,
Button3.Click, Button4.Click, Button5.Click, Button6.Click, Button7.Click,
Button8.Click, Button9.Click, Button11.Click
TextBox1.Text = TextBox1.Text & sender.text
End Sub
Kemudian Atur
Properties Button2
Locked
|
True
|
Text
|
2
|
Atur
Properties Button3
Locked
|
True
|
Text
|
3
|
Atur
Properties Button4
Locked
|
True
|
Text
|
4
|
Atur
Properties Button5
Locked
|
True
|
Text
|
5
|
Atur
Properties Button6
Locked
|
True
|
Text
|
6
|
Atur
Properties Button7
Locked
|
True
|
Text
|
7
|
Atur
Properties Button8
Locked
|
True
|
Text
|
8
|
Atur
Properties Button9
Locked
|
True
|
Text
|
9
|
Atur
Properties Button10
Locked
|
True
|
Text
|
.
|
- Double Click Button. dan masukan code dibawah ini:
Private Sub
Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button10.Click
If InStr(TextBox1.Text, ".")
> 0 Then
Exit Sub
Else
TextBox1.Text = TextBox1.Text & "."
End If
End Sub
Atur
Properties Button11
Locked
|
True
|
Text
|
0
|
Atur
Properties Button12
Locked
|
True
|
Text
|
C
|
- Double click ButtonC dan masukan code:
Private Sub
Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button12.Click
TextBox1.Text = ""
End Sub
Atur
Properties Button13
Locked
|
True
|
Text
|
+
|
- Double click Button+ dan masukan code:
Private Sub
Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button13.Click
Operand1 = Val(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
[Operator] = "+"
End Sub
Atur
Properties Button14
Locked
|
True
|
Text
|
-
|
- Double click Button- dan masukan code:
Private Sub
Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button14.Click
Operand1 = Val(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
[Operator] = "-"
End Sub
Atur
Properties Button15
Locked
|
True
|
Text
|
*
|
- Double click Button* dan masukan code:
Private Sub
Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button15.Click
Operand1 = Val(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
[Operator] = "*"
End Sub
Atur
Properties Button16
Locked
|
True
|
Text
|
/
|
- Double click Button/ dan masukan code:
Private Sub
Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button16.Click
Operand1 = Val(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
[Operator] = "/"
End Sub
Atur
Properties Button17
Locked
|
True
|
Text
|
1/X
|
- Double click Button1/X dan masukan code:
Private Sub
Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button17.Click
Dim convert As Single
If TextBox1.Text <> 0 Then
convert = 1 / Val(TextBox1.Text)
TextBox1.Text = convert
End If
End Sub
Atur
Properties Button18
Locked
|
True
|
Text
|
+-
|
- Double click Button+- dan masukan code:
Private Sub
Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button18.Click
TextBox1.Text = -1 * TextBox1.Text
End Sub
Atur
Properties Button18
Locked
|
True
|
Text
|
=
|
- Double click Button= dan masukan code:
Private Sub
Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Button19.Click
Dim Result As Double
Operand2 = Val(TextBox1.Text)
'If [Operator] = "+" Then
' Result =
Operand1 + Operand2
'ElseIf [Operator] = "-" Then
' Result =
Operand1 - Operand2
'ElseIf [Operator] = "/" Then
' Result = Operand1
/ Operand2
'ElseIf [Operator] = "*" Then
' Result =
Operand1 * Operand2
'End If
Select Case
[Operator]
Case "+"
Result = Operand1 + Operand2
MsgBox(Result.ToString("#,###.00"),
MsgBoxStyle.Information, "Result")
TextBox1.Text = Result.ToString("#,###.00")
Case "-"
Result = Operand1 - Operand2
MsgBox(Result.ToString("#,###.00"),
MsgBoxStyle.Information, "Result")
TextBox1.Text = Result.ToString("#,###.00")
Case "/"
Result = Operand1 / Operand2
MsgBox(Result.ToString("#,###.00"),
MsgBoxStyle.Information, "Result")
TextBox1.Text = Result.ToString("#,###.00")
Case "*"
Result = Operand1 * Operand2
MsgBox(Result.ToString("#,###.00"),
MsgBoxStyle.Information, "Result")
TextBox1.Text = Result.ToString("#,###.00")
End Select
TextBox1.Text = Result.ToString("#,###.00")
End Sub
Jika Sudah Selesai Coba Debug, jika berhasil Save.
Selamat Mencoba dan
belajar Pemrograman Visual Basic ya.
Untuk File VB project saya akan saya share belakangan kalo ada yang request.
Sumber: Buatan Sendiri
Kalo Copas Kasih Source ya.
Membuat aplikasi kalkulator dari Visual Basic, VB.NET, Contoh
Aplikasi, Calculator, Coding,Pemrograman,Bikin Aplikasi,Membuat Aplikasi
sederhana.
APLIKASI KALKULATOR VB.NET
Reviewed by Unknown
on
15.33
Rating:
Tidak ada komentar:
Silahkan Meninggalkan Komentar, Berkomentarlah dengan Sopan dan terpelajar, Terimakasih support teman-teman sekalian.
Buat yang mau Copas jangan lupa cantumkan Sumber, karna blog ini diproteksi DMCA.