14 September 2011
calculator sederhana
Public Class calcanggih
Private Sub Btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn1.Click
'If Txt1.Text = "" And Txt2.Text = "" Then
' MessageBox.Show("ANGKA TIDAK BOLEH KOSONG", "INFORMASI", MessageBoxButtons.OK, MessageBoxIcon.Hand)
'End If
If Txt3.Text = "" And Txt1.Text <> "" And Txt2.Text <> "" Then 'arti dar <> adalah tidaksamadengan
If Cmb1.Text = "-" Then
Txt3.Text = CInt(Txt1.Text) - CInt(Txt2.Text)
End If
If Cmb1.Text = "/" Then
Txt3.Text = CInt(Txt1.Text) / CInt(Txt2.Text)
End If
If Cmb1.Text = "*" Then
Txt3.Text = CInt(Txt1.Text) * CInt(Txt2.Text)
End If
If Cmb1.Text = "+" Then
Txt3.Text = CInt(Txt1.Text) + CInt(Txt2.Text)
End If
ElseIf Txt2.Text = "" And Txt1.Text <> "" And Txt3.Text <> "" Then
If Cmb1.Text = "-" Then
Txt2.Text = CInt(Txt1.Text) - CInt(Txt3.Text)
End If
If Cmb1.Text = "/" Then
Txt2.Text = CInt(Txt1.Text) / CInt(Txt3.Text)
End If
If Cmb1.Text = "*" Then
Txt2.Text = CInt(Txt3.Text) / CInt(Txt1.Text)
End If
If Cmb1.Text = "+" Then
Txt2.Text = CInt(Txt3.Text) - CInt(Txt1.Text)
End If
ElseIf Txt1.Text = "" And Txt2.Text <> "" And Txt3.Text <> "" Then
If Cmb1.Text = "-" Then
Txt1.Text = CInt(Txt3.Text) + CInt(Txt2.Text)
End If
If Cmb1.Text = "/" Then
Txt1.Text = CInt(Txt2.Text) * CInt(Txt3.Text)
End If
If Cmb1.Text = "*" Then
Txt1.Text = CInt(Txt3.Text) / CInt(Txt2.Text)
End If
If Cmb1.Text = "+" Then
Txt1.Text = CInt(Txt3.Text) - CInt(Txt2.Text)
End If
End If
End Sub
End Class
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar