6. 4. Setelah aplikasi di buka, lalu klik file new project windows
form application. Dan pada kolom nama beri nama CALCULATOR
7. 5. Pada toolbox all windows form, tambahkan 19 button dan 1 text
box kedalam FORM anda, dan susun lah seperti pada nomor 6
8. 6. Inilah hasil setelah di susun
7. Lalu editlah pada properties Form1 sesuai table di bawah ini
FormBorderStyle Fixed 3D
Icon (*bebas tapi harus .ico)
MaximizeBox False
Start Position Center Screen
Text Calculator
9. - Klik 2 kali form nya, lalu di bawah public class form1 masukan
kode di bawah ini
Dim Operand1 AsDouble
Dim Operand2 AsDouble
Dim [Operator] AsString
8. Lalu editlah pada properties Button1 sesuai tabel di bawah ini
Locked True
Text 1
- Double click Button 1 dan masukan kode di bawah ini
PrivateSub 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
EndSub
9. Lalu editlah properties button button berikut
- Properties pada button 2
Locked True
Text 2
- Properties pada button 3
Locked True
Text 3
- Properties pada button 4
Locked True
Text 4
10. - Properties pada button 5
Locked True
Text 5
- Properties pada button 6
Locked True
Text 6
- Properties pada button 7
Locked True
Text 7
- Properties pada button 8
Locked True
Text 8
- Properties pada button 9
Locked True
Text 9
- Properties pada button 10
Locked True
Text .
10. Double click Button . , dan masukan code di bawah ini
11. PrivateSub 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 &"."
EndIf
EndSub
- Properties pada button 11
Locked True
Text 0
- Properties pada button 12
ForeColor (bebas, sesuka anda)
Locked True
Text C
11.Double click button C dan masukan code di bawah ini
PrivateSub Button12_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button12.Click
TextBox1.Text = ""
EndSub
12. Properties pada button 13
ForeColor (bebas, sesuka anda)
Locked True
Text +
Double click button + , dan masukan kode di bawah ini
12. PrivateSub Button13_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button13.Click
Operand1 = Val(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
[Operator] = "+"
EndSub
13. Properties pada button 14
ForeColor (bebas, sesuka anda)
Locked True
Text -
Double click button - , dan masukan code di bawah ini
PrivateSub Button14_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button14.Click
Operand1 = Val(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
[Operator] = "-"
EndSub
14. Properties pada button 15
ForeColor (bebas, sesuka anda)
Locked True
Text *
Double click button * , dan masukan kode di bawah ini
PrivateSub Button14_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button14.Click
Operand1 = Val(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
[Operator] = "*"
13. EndSub
15. Pada properties button 16
ForeColor (bebas, sesuka anda)
Locked True
Text /
- Double click button / , dan masukan code dibawah ini
PrivateSub Button16_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button16.Click
Operand1 = Val(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
[Operator] = "/"
EndSub
16. Pada properties button 17
Locked True
Text 1/x
- Double click button 1/x , dan masukan code di bawah ini
PrivateSub Button17_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button17.Click
Dim convert AsSingle
If TextBox1.Text <> 0 Then
convert = 1 / Val(TextBox1.Text)
TextBox1.Text = convert
EndIf
EndSub
14. 17. Pada properties button 18
Locked True
Text +-
- Double click button +- , dan masukan code di bawah ini
PrivateSub Button18_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button18.Click
TextBox1.Text = -1 * TextBox1.Text
EndSub
18. Properties pada button 19
Locked True
Text =
- Double click button = , dan masukan code di bawah ini:
PrivateSub Button19_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button19.Click
Dim Result AsDouble
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
SelectCase [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"),
15. MsgBoxStyle.Information, "Result")
TextBox1.Text = Result.ToString("#,###.00")
EndSelect
TextBox1.Text = Result.ToString("#,###.00")
EndSub
EndClass
19. Sebelum melakukan komplikasi program, double click my
project pada colom solution explorer, pilih Assembly Information
dan kalian bias mengisi penjelasan atas software yang kaliat buat
ini, dan pilih icon sesuka kalian (*.ico)
16. 20. Dan ini lah hasil ketika gambar sudah di RUN, dan tidak
terjadi DEBUG atau eror