Minggu, 22 Maret 2020

Visual Lanjutan Praktek Kasus 4(OPERATOR)

Public Class Form2
    Public jari As Integer
    Public luas, keliling As Double

    Private Sub TextBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

        If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled = True

        If (e.KeyChar = Chr(13)) Then
            Const phi = 3.14
            jari = Val(TextBox1.Text)
            luas = phi * jari * jari
            keliling = 2 * phi * jari
            TextBox2.Text = luas
            TextBox3.Text = keliling
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim pesan As String
        pesan = MsgBox("yakin mau Keluar?", vbYesNo, "Konfirmasi")
        If pesan = vbYes Then
            Close()
            End
        End If
    End Sub
End Class

Tidak ada komentar:

Posting Komentar