Membuat Kalkulator Sederhana dengan Visual Basic 6.0
No.
|
Kontrol
|
Properties
|
1.
|
Commandbutton1
|
Name : cmd_1
Caption : 1
|
2.
|
Commandbutton2
|
Name : cmd_2
Caption : 2
|
3.
|
Commandbutton3
|
Name : cmd_3
Caption : 3
|
4.
|
Commandbutton4
|
Name : cmd_4
Caption : 4
|
5.
|
Commandbutton5
|
Name : cmd_5
Caption : 5
|
6.
|
Commandbutton6
|
Name : cmd_6
Caption : 6
|
7.
|
Commandbutton7
|
Name : cmd_7
Caption : 7
|
8.
|
Commandbutton8
|
Name : cmd_8
Caption : 8
|
9.
|
Commandbutton9
|
Name : cmd_9
Caption : 9
|
10.
|
Commandbutton10
|
Name : cmd_0
Caption : 0
|
11.
|
Commandbutton11
|
Name : cmd_hasil
Caption : =
|
12.
|
Commandbutton12
|
Name : cmd_tambah
Caption : +
|
13.
|
Commandbutton13
|
Name : cmd_kurang
Caption : -
|
14.
|
Commandbutton14
|
Name : cmd_kali
Caption : x
|
15.
|
Commandbutton15
|
Name : cmd_bagi
Caption : /
|
16.
|
Textbox
|
Name : txtNumber
Text :
|
17.
|
Label 1
|
Name : Label1
Caption : Timoresse
Kalkulator
|
Dim mfirst As Single Dim msecond As Single Dim manswer As Single Dim mbutton As Integer Private Sub cmd_0_Click() txtNumber = txtNumber + "0" End Sub Private Sub cmd_1_Click() txtNumber = txtNumber + "1" End Sub Private Sub cmd_2_Click() txtNumber = txtNumber + "2" End Sub Private Sub cmd_3_Click() txtNumber = txtNumber + "3" End Sub Private Sub cmd_4_Click() txtNumber = txtNumber + "4" End Sub Private Sub cmd_5_Click() txtNumber = txtNumber + "5" End Sub Private Sub cmd_6_Click() txtNumber = txtNumber + "6" End Sub Private Sub cmd_7_Click() txtNumber = txtNumber + "7" End Sub Private Sub cmd_8_Click() txtNumber = txtNumber + "8" End Sub Private Sub cmd_9_Click() txtNumber = txtNumber + "9" End Sub Private Sub cmd_bagi_Click() mbutton = 4 mfirst = Val(txtNumber) txtNumber = "" End Sub Private Sub cmd_hasil_Click() msecond = Val(txtNumber) Select Case mbutton Case Is = 1 manswer = mfirst + msecond Case Is = 2 manswer = mfirst - msecond Case Is = 3 manswer = mfirst * msecond Case Is = 4 manswer = mfirst / msecond End Select txtNumber = manswer End Sub Private Sub cmd_kali_Click() mbutton = 3 mfirst = Val(txtNumber) txtNumber = "" End Sub Private Sub cmd_kurang_Click() mbutton = 2 mfirst = Val(txtNumber) txtNumber = "" End Sub Private Sub cmd_tambah_Click() mbutton = 1 mfirst = Val(txtNumber) txtNumber = "" End SubSekarang tekan F5 untuk menjalankan program.. silahkan coba program anda.
Download tutorial versi PDF klik disini