Lompat ke konten Lompat ke sidebar Lompat ke footer

Membuat Calcullator (Aritmatika) Fungsi If - Visual Basic

Design program : 


Atur popertinya :

Kode kodingnya (secripnya) :
Public Class Form1  
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.Text = "Latihan Perhitungan Aritmatika"
    End Sub
    Private Sub btTambah_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btTambah.Click
        Dim b1, b2 As New Integer
        Dim h As New Double
        b1 = Val(txtBil1.Text)
        b2 = Val(txtBil2.Text)
        h = b1 + b2
        txtHasil.Text = h
    End Sub
    Private Sub btKurang_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btKurang.Click
        Dim b1, b2 As New Integer
        Dim h As New Double
        b1 = Val(txtBil1.Text)
        b2 = Val(txtBil2.Text)
        h = b1 - b2
        txtHasil.Text = h
    End Sub
    Private Sub btKali_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btKali.Click
        Dim b1, b2 As New Integer
        Dim h As New Double
        b1 = Val(txtBil1.Text)
        b2 = Val(txtBil2.Text)
        h = b1 * b2
        txtHasil.Text = h
    End Sub
    Private Sub btBagi_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btBagi.Click
        Dim b1, b2 As New Integer
        Dim h As New Double
        b1 = Val(txtBil1.Text)
        b2 = Val(txtBil2.Text)
        h = b1 / b2
        txtHasil.Text = h
    End Sub
    Private Sub btNew_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btNew.Click
        Me.txtBil1.Clear()
        Me.txtBil2.Clear()
        Me.txtHasil.Clear()
        Me.txtBil1.Focus()
    End Sub
    Private Sub btClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btClose.Click
        Me.Close()
    End Sub
    Private Sub txtBil1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtBil1.KeyPress
        If e.KeyChar = Chr(13) Then
            Me.txtBil2.Focus()
        End If
    End Sub

    Private Sub txtBil2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtBil2.KeyPress
        If e.KeyChar = Chr(13) Then
            Me.btNew.Focus()
        End If
    End Sub
End Class

Posting Komentar untuk "Membuat Calcullator (Aritmatika) Fungsi If - Visual Basic"