Wahhh Pernah Terpikir gak di fikiran ssobat ayti kalo sobat juga bisa membuat
kalkulator sederhana loch dengan menggunakan Software Microsoft Visual Basic.
dan Buat Temen2 yg Kuliah di BSI, Apalagi Jurusan Komputer Akuntansi dan Jurusan Manajemen Informatika,
Pastinya ada dong mata kuliah "Pemrograman Visual 1 dan Pemrograman Visual II". :D
Ohya Berhubung Artikel ini asli buatan saya,, silahkan bagi yg ingin Copy Paste Mohon cantumkan yaa link blog saya ^_^ hehe,,
oke langsung Sedot aja gan mengenai langkah2 pembuatannya..
Pertama Seperti Biasa, Buka Program Microsoft Visual Basic..
Lalu Pilih STANDART.EXE
DesignLah Form Seperti Gambar Berikut :
Kamudian Atur Lah Properties Pada Masing2 Objek. Aturlah seperti Berikut ini :
Command Button 0, 00, 1, 2, 3, 4, 5, 6, 7, 8, 9
Name : cmdangka
Command Button (.)
Name : cmdtitik
Command Button +, -, /, *
Name : cmdop
Command Button +/-
Name : cmdplusminus
Command Button =
Name : cmdsmdgn
Command Button “Bersihin”
Name : cmdclear
Command Button “Hidup”
Name : cmdon
Command Button “Mati”
Name : cmdoff
Text2
(Kotak Putih Pertama)
Text1
(Kotak Putih kedua)
Lalu Masukan SourCe Kode Berikut ke dalam Form yg barusan kamu buat :
Dim ans, b, c, hasil, sudut As Double
Dim a As String
Dim i, X As Integer
Dim no1 As Double, cnt1 As Integer
Dim op As String, op1 As String
Private Sub cmdangka_Click(Index As Integer)
If Text1.Text = "0" Then
Text1.Text = ""
End If
If X = 0 Then
Text1.Text = ""
X = X + 1
End If
Text1.Text = Text1.Text + cmdangka(Index).Caption
Text2.Text = Text2.Text + cmdangka(Index).Caption
End Sub
Private Sub cmdclear_Click()
Select Case Index
Case 0
cnt1 = 0
X = 0
Text1.Text = ""
Text2.Text = ""
Text1.Visible = True
Case 1
Text2.Text = Mid(Text2.Text, 1, Len(Text2.Text) - 1)
End Select
End Sub
Private Sub Cmdkoma_Click()
Text1.Text = Text1.Text + "."
Text2.Text = Text2.Text + "."
End Sub
Private Sub cmdoff_Click()
Text1.Visible = False
Text2.Visible = False
cmdclear.Enabled = False
cmdoff.Enabled = False
cmdon.Enabled = True
End Sub
Private Sub cmdon_Click()
Text1.Visible = True
Text2.Visible = True
cmdclear.Enabled = True
cmdoff.Enabled = True
cmdon.Enabled = False
End Sub
Private Sub cmdop_Click(Index As Integer)
X = 0
If cnt1 > 0 Then
Select Case op
Case "+"
ans = no1 + Text1.Text
Text1.Text = ans
no1 = Text1.Text
op = cmdop(Index).Caption
Case "-"
ans = no1 - Text1.Text
Text1.Text = ans
no1 = Text1.Text
op = cmdop(Index).Caption
Case "/"
ans = no1 / Text1.Text
Text1.Text = ans
no1 = Text1.Text
op = cmdop(Index).Caption
Case "*"
ans = no1 * Val(Text1.Text)
Text1.Text = ans
no1 = Text1.Text
op = cmdop(Index).Caption
Case "^"
ans = no1 ^ Text1.Text
Text1.Text = ans
no1 = Text1.Text
op = cmdop(Index).Caption
End Select
Else
no1 = Val(Text1.Text)
op = cmdop(Index).Caption
cnt1 = cnt1 + 1
End If
Text2.Text = Text2.Text + cmdop(Index).Caption
End Sub
Private Sub cmdplusminus_Click()
Text1.Text = Text1.Text * (-1)
Text2.Text = Text2.Text * (-1)
End Sub
Private Sub cmdsmdgn_Click()
cnt1 = 0
Select Case op
Case "+"
ans = Text1.Text + no1
If cnt = 0 Then
no1 = Text1.Text
cnt = cnt + 1
End If
Text1.Text = ans
Case "-"
If cnt > 0 Then
Text1.Text = no1
no1 = ans
End If
ans = no1 - Text1.Text
no1 = Text1.Text
Text1.Text = ans
cnt = cnt + 1
Case "*"
ans = no1 * Text1.Text
If cnt = 0 Then
no1 = Text1.Text
cnt = cnt + 1
End If
Text1.Text = ans
Case "/"
If cnt > 0 Then
Text1.Text = no1
no1 = ans
End If
If Text1.Text = "0" Then
i = MsgBox("Divide by zero error", vbExclamation + vbOKOnly, "ERROR")
Else
ans = no1 / Text1.Text
no1 = Text1.Text
Text1.Text = ans
cnt = cnt + 1
End If
Case "^"
ans = no1 ^ Text1.Text
Text1.Text = ans
End Select
Text1.Text = Text1.Text
Text1.Visible = True
End Sub
Private Sub cmdtitik_Click()
Text1.Text = Text1.Text + "."
Text2.Text = Text2.Text + "."
End Sub
Private Sub Form_Activate()
Text1.Visible = False
Text2.Visible = False
cmdclear.Enabled = False
End Sub
Private Sub mnclear_Click()
Select Case Index
Case 0
cnt1 = 0
X = 0
Text1.Text = ""
Text2.Text = ""
Text1.Visible = True
Case 1
Text2.Text = Mid(Text2.Text, 1, Len(Text2.Text) - 1)
End Select
End Sub
Private Sub mnexit_Click()
pesan = MsgBox("Loe Yakin Ingin Keluar dari Aplikasi ini..?", vbQuestion + vbYesNo, "Konfirmasi")
If pesan = vbYes Then
End
End If
End Sub
Private Sub mnhidup_Click()
Text1.Visible = True
Text2.Visible = True
Shape1.BorderColor = Red
cmdclear.Enabled = True
cmdoff.Enabled = True
cmdon.Enabled = False
End Sub
Private Sub mnmati_Click()
Text1.Visible = False
Text2.Visible = False
cmdclear.Enabled = False
cmdoff.Enabled = False
cmdon.Enabled = True
End Sub
* * *
Nah Coba Sekarang Silahkan Kamu Running,,
Semoga Berhasil dan Bermanfaat ^_^..
Ini adalah ScreenShoot Hasil Kalkulator Buatan Saya
gan ada soft copynya ga? butuh nih...
BalasHapusada kok gan,, kan waktu itu udah saya posting, liat aja disini :
BalasHapushttp://ayti-copast.blogspot.com/2013/01/download-source-code-dan-project-program-kalkulator-sederhana.html