Pertama Buatlah Form/layout nya seperti Gambar di Bawah ini :
Setalah Formnya sesuai serta pengatura properti-propertinya selanjutnya kita masuk ke penyusunan scriptnya.
buatlah seperti dibawah ini :
Private LastOperator As String
Private FirstPart As String
Private Sub cmdClear_Click()
FirstPart = ""
LastOperator = ""
text1.Text = ""
End Sub
Private Sub cmdEquals_Click()
Select Case LastOperator
Case Is = "+"
text1.Text = Val(FirstPart) + Val(text1.Text)
Case Is = "-"
text1.Text = Val(FirstPart) - Val(text1.Text)
Case Is = "/"
text1.Text = Val(FirstPart) / Val(text1.Text)
Case Is = "*"
text1.Text = Val(FirstPart) * Val(text1.Text)
End Select
FirstPart = ""
LastOperator = ""
End Sub
Private Sub cmdOp_Click(Index As Integer)
LastOperator = cmdop(Index).Caption
FirstPart = text1.Text
text1.Text = ""
End Sub
Private Sub Cmdangka_Click(Index As Integer)
text1.Text = text1.Text + cmdangka(Index).Caption
End Sub
Private FirstPart As String
Private Sub cmdClear_Click()
FirstPart = ""
LastOperator = ""
text1.Text = ""
End Sub
Private Sub cmdEquals_Click()
Select Case LastOperator
Case Is = "+"
text1.Text = Val(FirstPart) + Val(text1.Text)
Case Is = "-"
text1.Text = Val(FirstPart) - Val(text1.Text)
Case Is = "/"
text1.Text = Val(FirstPart) / Val(text1.Text)
Case Is = "*"
text1.Text = Val(FirstPart) * Val(text1.Text)
End Select
FirstPart = ""
LastOperator = ""
End Sub
Private Sub cmdOp_Click(Index As Integer)
LastOperator = cmdop(Index).Caption
FirstPart = text1.Text
text1.Text = ""
End Sub
Private Sub Cmdangka_Click(Index As Integer)
text1.Text = text1.Text + cmdangka(Index).Caption
End Sub
jalankan programnya. so jadilah personal kalkulator buatan sendiri.
Join This Site Show Konversi KodeHide Konversi Kode Show EmoticonHide Emoticon