MEMBUAT KAKULATOR SEDERHANA
(DENGAN MENGGUNAKAN MENGUNAKAN VISUAL BASIK 6.0)
(Tugas wat minggu depan
ne,,, <jo)
Start > Microsoft
visual studio > visual Basic 6.0 > Ok > standart Exe
Yang pertama harus
disiapkan adalah form yang bentuknya kayak gni ni,,,
Yakni form yang berisi 1
text box, dan 18 comandbutton (desain sesuai selera)
Keterangan:
KOMPONEN
|
PROPERTY
|
NILAI
|
Form1
|
Caption
Border stile
Start position
|
Kalkulator
3-fixed dialog
2-center screen
|
Text1
|
Name
Font
|
Text
Font = Trebuchet MS
Font stile = Bold
Size = 14
|
Command1
|
Name
caption
|
Cmd_1
1
|
Command2
|
Name
caption
|
Cmd_2
2
|
Command3
|
Name
Caption
|
Cmd_3
3
|
Command4
|
Name
Caption
|
Cmd_4
4
|
Command5
|
Name
Caption
|
Cmd_5
5
|
Command6
|
Name
Caption
|
Cmd_6
6
|
Command7
|
Name
Caption
|
Cmd_7
7
|
Command8
|
Name
Caption
|
Cmd_8
8
|
Command9
|
Name
Caption
|
Cmd_9
9
|
Command10
|
Name
Caption
|
Cmd_0
0
|
Command11
|
Name
Caption
|
Cmd_kali
*
|
Command12
|
Name
Caption
|
Cmd_bagi
/
|
Command13
|
Name
caption
|
Cmd_tambah
+
|
Command14
|
Name
Caption
|
Cmd_kurang
-
|
Command15
|
Name
Caption
|
Cmd_sama_dengan
=
|
Command16
|
Name
Caption
|
Cmd_C
C
|
Command17
|
Name
Caption
|
Cmd_off
OFF
|
Kemudian double klik aja pada form lalu
ketik project codenya seperti ini
nih,,,<<
Dim Nilai1, Nilai2, Hasil As Double
Dim Operator As String
Private Sub Cmd_0_Click()
If Text = "0" Then
Text = "0"
Else
Text = Text & "0"
End If
End Sub
Private Sub Cmd_1_Click()
If Text = "0" Then
Text = "1"
Else
Text = Text & "1"
End If
End Sub
Private Sub Cmd_2_Click()
If Text = "2" Then
Text = "2"
Else
Text = Text & "2"
End If
End Sub
Private Sub Cmd_3_Click()
If Text = "3" Then
Text = "3"
Else
Text = Text & "3"
End If
End Sub
Private Sub Cmd_4_Click()
If Text = "4" Then
Text = "4"
Else
Text = Text & "4"
End If
End Sub
Private Sub Cmd_5_Click()
If Text = "5" Then
Text = "5"
Else
Text = Text & "5"
End If
End Sub
Private Sub Cmd_6_Click()
If Text = "6" Then
Text = "6"
Else
Text = Text & "6"
End If
End Sub
Private Sub Cmd_7_Click()
If Text = "7" Then
Text = "7"
Else
Text = Text & "7"
End If
End Sub
Private Sub Cmd_8_Click()
If Text = "8" Then
Text = "8?"
Else
Text = Text & "8"
End If
End Sub
Private Sub Cmd_9_Click()
If Text = "9" Then
Text = "9?"
Else
Text = Text & "9"
End If
End Sub
Private Sub Cmd_bagi_Click()
If Nilai1 = 0 Then
Nilai1 = Val(Text)
Else
Nilai1 = Nilai1 / Val(Text)
End If
Operator = "/"
Text = ""
End Sub
Private Sub Cmd_c_Click()
Text = ""
Nilai1 = 0
Hasil = 0
Operator = ""
End Sub
Private Sub Cmd_kali_Click()
If Nilai1 = 0 Then
Nilai1 = Val(Text)
Else
Nilai1 = Nilai1 * Val(Text)
End If
Operator = "X"
Text = ""
End Sub
Private Sub Cmd_kurang_Click()
If Nilai1 = 0 Then
Nilai1 = Val(Text)
Else
Nilai1 = Nilai1 - Val(Text)
End If
Operator = "-"
Text = ""
End Sub
Private Sub Cmd_off_Click()
End
End Sub
Private Sub Cmd_sama_dengan_Click()
If Operator = "^" Then
Hasil = Nilai1 ^ Val(Text)
Text = Hasil
ElseIf Operator = "X" Then
Hasil = Nilai1 * Val(Text)
Text = Hasil
ElseIf Operator = "/" Then
Hasil = Nilai1 / Val(Text)
Text = Hasil
ElseIf Operator = "MOD" Then
Hasil = Nilai1 Mod Val(Text)
Text = Hasil
ElseIf Operator = "+" Then
Hasil = Nilai1 + Val(Text)
Text = Hasil
ElseIf Operator = "-" Then
Hasil = Nilai1 - Val(Text)
Text = Hasil
End If
Nilai1 = 0
Operator = ""
End Sub
Private Sub Cmd_tambah_Click()
If Nilai1 = 0 Then
Nilai1 = Val(Text)
Else
Nilai1 = Nilai1 + Val(Text)
End If
Operator = "+"
Text = ""
End Sub
Private Sub Cmd_titik_Click()
Text = Text & "."
End Sub
Gimana Mudah khan,,
Okeyyy
selamat
mencobaa……
<jo
Komentar ini telah dihapus oleh pengarang.
BalasHapusyA tHankzzzz
BalasHapus