Wednesday, January 16, 2013

Contoh Program Menghitung Luas Persegi Panjang Menggunakan Visual Studio 2008


Setting Properties


source code :






Public Class Form1

    Private Sub Proses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Proses.Click
        Luas.Text = Val(Panjang.Text) * Val(Lebar.Text)
    End Sub

    Private Sub Batal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Batal.Click
        Panjang.Text = ""
        Lebar.Text = ""
        Luas.Text = ""
    End Sub

    Private Sub Keluar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Keluar.Click
        Dim x As String
        x = MsgBox("Yakin Ingin Keluar?", MsgBoxStyle.YesNo)
        If x = vbYes Then
            End
        Else
            MsgBox("Jumpa Lagi Nih...!")
        End If
    End Sub

    Private Sub Panjang_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Panjang.KeyPress
        If Asc(e.KeyChar) = 13 Then
            Lebar.Focus()
        End If
    End Sub

    Private Sub Lebar_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Lebar.KeyPress
        If Asc(e.KeyChar) = 13 Then
            Luas.Text = Val(Panjang.Text) * Val(Lebar.Text)
        End If
    End Sub

    Private Sub Panjang_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panjang.TextChanged

    End Sub
End Class

No comments:

Post a Comment