Program kalkulator sederhana dengan vb.net 2008
Membuat Program Aplikasi Kalkulator dengan Vb.Net adalah program pelajaran sederhana dalam pemogroman, karena disini lah awal dari kesempurnaan progam. Kami berharap Semoga Membuat Program Aplikasi Kalkulator dengan Vb.Net ini dapat bermanfaat bagi para programer dasar.
Berikut ini adalah listing Program Membuat Program Aplikasi kalkulator dengan Vb.Net,semoga dapat membantu;
Public Class KALKULATOR
Dim operand1 As Double
Dim [operator] As String
Dim baru As Boolean = True
Dim temp As Double
Dim operand2 As Double
Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click, btn1.Click, btn2.Click, btn3.Click,btn4.Click, btn5.Click, btn6.Click, btn7.Click, btn8.Click, bnt9.Click
TextBox1.Text = TextBox1.Text & sender.Text
End Sub
Private Sub btntambah_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntambah.Click
If baru = True Then
operand1 = Val(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
[operator] = "+"
ElseIf baru = False Then
If [operator] = "+" Then
temp = operand1 + Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
ElseIf [operator] = "-" Then
temp = operand1 - Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
ElseIf [operator] = "x" Then
temp = operand1 * Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
ElseIf [operator] = ":" Then
temp = operand1 / Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
End If
End If
baru = False
End Sub
Private Sub btnkurang_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkurang.Click
If baru = True Then
operand1 = Val(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
[operator] = "-"
ElseIf baru = False Then
If [operator] = "+" Then
temp = operand1 + Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
ElseIf [operator] = "-" Then
temp = operand1 - Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
ElseIf [operator] = "x" Then
temp = operand1 * Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
ElseIf [operator] = ":" Then
temp = operand1 / Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
End If
End If
baru = False
End Sub
Private Sub btnkali_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnkali.Click
If baru = True Then
operand1 = Val(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
[operator] = "x"
ElseIf baru = False Then
If [operator] = "+" Then
temp = operand1 + Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
ElseIf [operator] = "-" Then
temp = operand1 - Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
ElseIf [operator] = "x" Then
temp = operand1 * Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
ElseIf [operator] = ":" Then
temp = operand1 / Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
End If
End If
baru = False
End Sub
Private Sub btnbagi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbagi.Click
If baru = True Then
operand1 = Val(TextBox1.Text)
TextBox1.Text = ""
TextBox1.Focus()
[operator] = ":"
ElseIf baru = False Then
If [operator] = "+" Then
temp = operand1 + Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
ElseIf [operator] = "-" Then
temp = operand1 - Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
ElseIf [operator] = "x" Then
temp = operand1 * Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
ElseIf [operator] = ":" Then
temp = operand1 / Val(TextBox1.Text)
operand1 = temp
TextBox1.Text = ""
[operator] = "+"
End If
End If
baru = False
End Sub
Private Sub btnsamadengan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsamadengan.Click
Dim hasil As Double
operand2 = Val(TextBox1.Text)
Select Case [operator]
Case "+"
hasil = operand1 + operand2
TextBox1.Text = hasil.ToString
baru = True
Case "-"
hasil = operand1 - operand2
TextBox1.Text = hasil.ToString
Case ":"
hasil = operand1 / operand2
TextBox1.Text = hasil.ToString
Case "x"
hasil = operand1 * operand2
TextBox1.Text = hasil.ToString
baru = True
End Select
End Sub
Private Sub btntitik_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntitik.Click
If InStr(TextBox1.Text, ".") > 0 Then
Exit Sub
Else
TextBox1.Text = TextBox1.Text & "."
End If
End Sub
Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclear.Click
TextBox1.Text = ""
operand1 = 0
temp = 0
baru = True
End Sub
End Class
semoga dapat bermanfaat
Subscribe to:
Post Comments (Atom)
0 Response to "cara membuat kalkulator sederhana"
Post a Comment