kalkulator vb.net
program ini yang membuat tidak saya sendiri tapi saya mengetik
dari modul praktikum pemrograman teknik informatika 2010 STTA
Yogyakarta.
inilah tampilannya
dan ini sourcecodenya
inilah tampilannya
dan ini sourcecodenya
001 | Public Class Form1 |
002 |
003 | Inherits System.Windows.Forms.Form |
004 | Const pi As Single = 3.14 |
005 | Public hasil As Single |
006 | Public operator As Byte |
007 |
008 | Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click |
009 | TextBox1.Text = TextBox1.Text & pi |
010 | End Sub |
011 |
012 | Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click |
013 | TextBox1.Text = "" |
014 | hasil = 0 |
015 | TextBox1.Focus() |
016 | End Sub |
017 |
018 | Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click |
019 | operator = "1" |
020 | hasil = Single.Parse(TextBox1.Text) |
021 | TextBox1.Text = "" |
022 | TextBox1.Focus() |
023 | End Sub |
024 |
025 | Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click |
026 | operator = "2" |
027 | hasil = Single.Parse(TextBox1.Text) |
028 | TextBox1.Text = "" |
029 | TextBox1.Focus() |
030 |
031 | End Sub |
032 |
033 | Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click |
034 | operator = "3" |
035 | hasil = Single.Parse(TextBox1.Text) |
036 | TextBox1.Text = "" |
037 | TextBox1.Focus() |
038 | End Sub |
039 |
040 | Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click |
041 | operator = "4" |
042 | hasil = Single.Parse(TextBox1.Text) |
043 | TextBox1.Text = "" |
044 | TextBox1.Focus() |
045 | End Sub |
046 |
047 | Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click |
048 | If operator = 1 Then |
049 | hasil += Single.Parse(TextBox1.Text) |
050 | TextBox1.Text = hasil |
051 | ElseIf operator = 2 Then |
052 | hasil -= Single.Parse(TextBox1.Text) |
053 | TextBox1.Text = hasil |
054 | ElseIf operator = 3 Then |
055 | hasil *= Single.Parse(TextBox1.Text) |
056 | TextBox1.Text = hasil |
057 | ElseIf operator = 4 Then |
058 | hasil /= Single.Parse(TextBox1.Text) |
059 | TextBox1.Text = hasil |
060 |
061 | End If |
062 | End Sub |
063 |
064 | Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click |
065 | TextBox1.Text = TextBox1.Text + "." |
066 | TextBox1.Focus() |
067 |
068 | End Sub |
069 |
070 | Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click |
071 | TextBox1.Text = TextBox1.Text & "0" |
072 |
073 | End Sub |
074 |
075 | Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click |
076 | TextBox1.Text = TextBox1.Text & "1" |
077 | End Sub |
078 |
079 | Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click |
080 | TextBox1.Text = TextBox1.Text & "2" |
081 | End Sub |
082 |
083 | Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click |
084 | TextBox1.Text = TextBox1.Text & "3" |
085 | End Sub |
086 |
087 | Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click |
088 | TextBox1.Text = TextBox1.Text & "4" |
089 | End Sub |
090 |
091 | Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click |
092 | TextBox1.Text = TextBox1.Text & "5" |
093 | End Sub |
094 |
095 | Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click |
096 | TextBox1.Text = TextBox1.Text & "6" |
097 | End Sub |
098 |
099 | Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click |
100 | TextBox1.Text = TextBox1.Text & "7" |
101 | End Sub |
102 |
103 | Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click |
104 | TextBox1.Text = TextBox1.Text & "8" |
105 | End Sub |
106 |
107 | Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click |
108 | TextBox1.Text = TextBox1.Text & "9" |
109 | End Sub |
110 | End Class |
| Sumber : http://bahrie27.wordpress.com/2010/04/11/program-kalkulator-dengan-visual-studio-net/http://bahrie27.wordpress.com/2010/04/11/program-kalkulator-dengan-visual-studio-net/ |
Tidak ada komentar:
Posting Komentar