VB.NET: Contoh Project Kalkulator Sederhana


Design UI

Code
Public Class Form1
    Dim Input1 As Integer
    Dim Input2 As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles MyBase.Load
        txtInput1.Text = 5
        txtInput2.Text = 2
        Input1 = txtInput1.Text
        Input2 = txtInput2.Text
    End Sub

   
Private Sub btnAdd_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles btnAdd.Click
        lblOutput.Text = Input1 + Input2
    End Sub

   
Private Sub btlSubtract_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles btlSubtract.Click
        lblOutput.Text = Input1 - Input2
    End Sub

   
Private Sub btnMultiply_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles btnMultiply.Click
        lblOutput.Text = Input1 * Input2
    End Sub

   
Private Sub btnDivide_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles btnDivide.Click
        lblOutput.Text = Input1 / Input2
    End Sub

   
Private Sub btdRDiv_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles btdRDiv.Click
        lblOutput.Text = Input1 \ Input2
    End Sub

   
Private Sub btnMod_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles btnMod.Click
        lblOutput.Text = Input1 Mod Input2
    End Sub

   
Private Sub btnPower_Click(ByVal sender As System.Object, _
            ByVal e As System.EventArgs) Handles btnPower.Click
        lblOutput.Text = Input1 ^ Input2
    End Sub

End Class


Runtime


Click here if you like this article.


Post a Comment

0 Comments