source :
Public Class Form1
'sub class hitung
'berfungsi
menghitung data sesuai kondisi
Sub hitung(ByVal a As Double, ByVal b As Double, ByRef c As String)
Dim d As Double
If c = "+" Then
d = a + b
cetak(d)
ElseIf
c = "-" Then
d = a - b
cetak(d)
ElseIf
c = "*" Then
d = a * b
cetak(d)
ElseIf
c = "/" Then
d = a / b
cetak(d)
ElseIf
c = "^" Then
d = a ^ b
cetak(d)
End If
End Sub
'sub class cetak
'berfungsi untuk
mencetak output
Sub cetak(ByVal e As Double)
TextBox3.Text = e
End Sub
'fungsi cekdata
'berfungsi untuk
mengecek data inputan
Private Function cekdata() As
Boolean
If
IsNumeric(TextBox1.Text) And
IsNumeric(TextBox2.Text) Then
Return
True
Else
Return
False
End If
End Function
'fungsi tombol 1
Private Sub Button1_Click(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If
cekdata() = True Then
If
RadioButton1.Checked Then
Label1.Text = "+"
hitung(TextBox1.Text,
TextBox2.Text, "+")
ElseIf
RadioButton2.Checked Then
Label1.Text = "-"
hitung(TextBox1.Text,
TextBox2.Text, "-")
ElseIf
RadioButton3.Checked Then
Label1.Text = "*"
hitung(TextBox1.Text,
TextBox2.Text, "*")
ElseIf
RadioButton4.Checked Then
Label1.Text = "/"
hitung(TextBox1.Text,
TextBox2.Text, "/")
ElseIf
RadioButton5.Checked Then
Label1.Text = "^"
hitung(TextBox1.Text,
TextBox2.Text, "^")
End
If
Else
MessageBox.Show("Inputan Harus Angka!!")
End If
End Sub
Semoga bermanfaat, salam.
Thnks Bro...
0 komentar:
Posting Komentar