Visua Basic merupakan salah satu perangkat lunak dengan kelebihan pada tampilan visualnya. Pada waktu semester 3 itu, dapat tugas untuk membuat kalkulator dengan visual basic.
caranya gampang-gampang susah...
masukkan sintax programnya sebagai berikut:
Public Class Form1
Dim Numbers() As Integer
Dim a, b, c, d As Boolean
Dim f, g, h, i As Double
Dim hasil As String
Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
If txtDisplay.Text = "" Then
txtDisplay.Text = ""
Else
txtDisplay.Text = txtDisplay.Text & "0"
End If
End Sub
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
txtDisplay.Text = txtDisplay.Text & "1"
End Sub
Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
txtDisplay.Text = txtDisplay.Text & "2"
End Sub
Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
txtDisplay.Text = txtDisplay.Text & "3"
End Sub
Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
txtDisplay.Text = txtDisplay.Text & "4"
End Sub
Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
txtDisplay.Text = txtDisplay.Text & "5"
End Sub
Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
txtDisplay.Text = txtDisplay.Text & "6"
End Sub
Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
txtDisplay.Text = txtDisplay.Text & "7"
End Sub
Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
txtDisplay.Text = txtDisplay.Text & "8"
End Sub
Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
txtDisplay.Text = txtDisplay.Text & "9"
End Sub
Private Sub btn11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDot.Click
If txtDisplay.Text = "." Then
txtDisplay.Text = ""
Else
txtDisplay.Text = txtDisplay.Text & "."
End If
btnDot.Enabled = False
End Sub
Private Sub btnPlus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPlus.Click
a = True
f = Val(txtDisplay.Text)
txtDisplay.Text = Nothing
End Sub
Private Sub btnMin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMin.Click
b = True
f = Val(txtDisplay.Text)
txtDisplay.Text = Nothing
End Sub
Private Sub btnKali_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKali.Click
c = True
f = Val(txtDisplay.Text)
txtDisplay.Text = Nothing
End Sub
Private Sub btnBagi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBagi.Click
d = True
f = Val(txtDisplay.Text)
txtDisplay.Text = Nothing
End Sub
Private Sub btnhasil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhasil.Click
h = Val(txtDisplay.Text)
If a = True Then
g = f + h
a = False
ElseIf b = True Then
g = f - h
b = False
ElseIf c = True Then
g = f * h
c = False
ElseIf d = True Then
g = f / h
d = False
Else
g = h
End If
txtDisplay.Text = g
End Sub
Private Sub btn17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn17.Click
i = Len(txtDisplay.Text)
txtDisplay.Text = Mid(txtDisplay.Text, 1, i - 1)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
f = Nothing
txtDisplay.Text = Nothing
g = Nothing
a = False
b = False
c = False
d = False
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If txtDisplay.Text = "" Then
txtDisplay.Text = ""
Else
txtDisplay.Text = txtDisplay.Text & "00"
End If
End Sub
End Class
0 comments:
Posting Komentar