Program Sederhana Vb.net Menghitung Luas Bangun Ruang

 

Contoh Program Sederhana VB.net menghitung luas bangun ruang. Berikut adalah codingnya :
1. Mencari Luas Lingkaran


Item yang digunakan : 

Kontrol

Properti

Nilai

Form 1

Name

FormLuasLingkaran

Text

Luas Lingkaran

Textbox1

Name

Txt_jari

TextAlign

Right

Textbox2

Name

Txt_luas

TextAlign

Right

Button1

Name

Btn_hitung

Text

Hitung

Button2

Name

Btn_batal

Text

Batal

Button 3

Name

Btn_keluar

text

Keluar

Untuk Codingnya tinggal copy dibawah ini : 

Public Class FormLuasLingkaran


    Private Sub btn_hitung_Click(sender As Object, e As EventArgs) Handles btn_hitung.Click


        Dim r As Double, phi As Double

        phi = 3.14

        r = Val(txt_jari.Text)

        If txt_jari.Text = "" Then

            MsgBox("informasi tidak lengkap", vbInformation, "Lingkaran")

        Else

            txt_luas.Text = phi * (r ^ 2)

            txt_jari.Text = r

        End If

    End Sub


    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        txt_luas.Enabled = False

    End Sub


    Private Sub btn_batal_Click(sender As Object, e As EventArgs) Handles btn_batal.Click

        txt_jari.Clear()

        txt_luas.Clear()

        txt_jari.Focus()

    End Sub


    Private Sub btn_keluar_Click(sender As Object, e As EventArgs) Handles btn_keluar.Click

        Me.Close()

    End Sub

End Class 


2. Menghitung Luas Tabung

Item yang digunakan : 
  

Kontrol

Properti

Nilai

Form 1

Name

FormLuasTabung

Text

Luas Tabung

Textbox1

Name

Txt_jari

TextAlign

Right

Textbox2

Name

Txt_luas

TextAlign

Right

Textbox3

Name

Txt_tinggi

 

TextAlign

Right

Button1

Name

Btn_hitung

Text

Hitung

Button2

Name

Btn_batal

Text

Batal

Button 3

Name

Btn_keluar

text

Keluar

Untuk Codingnya tinggal copy dibawah ini : 

Public Class FormLuasTabung

    Private Sub btn_hitung_Click(sender As Object, e As EventArgs) Handles btn_hitung.Click

        Dim r As Double, phi As Double


        phi = 3.14

        r = Val(txt_jari.Text)


        If txt_jari.Text = "" Then

            MsgBox("informasi tidak lengkap", vbInformation, "Tabung")


        Else

            txt_luas.Text = (2 * phi) * (r ^ 2) * txt_tinggi.Text

            txt_jari.Text = r


        End If

    End Sub


    Private Sub FormLuasTabung_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        txt_luas.Enabled = False

    End Sub


    Private Sub btn_batal_Click(sender As Object, e As EventArgs) Handles btn_batal.Click

        txt_jari.Clear()

        txt_tinggi.Clear()

        txt_luas.Clear()

        txt_jari.Focus()

    End Sub


    Private Sub btn_keluar_Click(sender As Object, e As EventArgs) Handles btn_keluar.Click

        Me.Close()

    End Sub

End Class


3. Program Mencari Luas Segitiga

Item yang digunakan :

Kontrol

Properti

Nilai

Form 1

Name

FormLuasSegitiga

Text

Luas Segitig

Textbox1

Name

Txt_alas

TextAlign

Right

Textbox2

Name

Txt_luas

TextAlign

Right

Textbox3

Name

Txt_tinggi

 

TextAlign

Right

Button1

Name

Btn_hitung

Text

Hitung

Button2

Name

Btn_batal

Text

Batal

Button 3

Name

Btn_keluar

text

Keluar

Untuk Codinganya bisa copy coding dibawah ini :

Public Class FormLuasSegitiga

    Private Sub btn_hitung_Click(sender As Object, e As EventArgs) Handles btn_hitung.Click

        Dim alas As Double, tinggi As Double, luas As Double

        alas = Val(txt_alas.Text)

        tinggi = Val(txt_tinggi.Text)

        luas = 0.5 * alas * tinggi

        txt_luas.Text = luas

        MsgBox("Data Berhasil dihitung", 0 + 64 + 0, "Informasi")

    End Sub

    Private Sub btn_batal_Click(sender As Object, e As EventArgs) Handles btn_batal.Click

        txt_alas.Clear()

        txt_tinggi.Clear()

        txt_luas.Clear()

        txt_alas.Focus()

    End Sub

    Private Sub btn_keluar_Click(sender As Object, e As EventArgs) Handles btn_keluar.Click

        Me.Close()

    End Sub

    Private Sub FormLuasSegitiga_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        txt_luas.Enabled = False

    End Sub

End Class


4. Program Mencari Luas Kerucut

Item yang digunakan : 

Kontrol

Properti

Nilai

Form 1

Name

FormLuaskerucut

Text

Luas Kerucut

Textbox1

Name

Txt_jari

TextAlign

Right

Textbox2

Name

Txt_Volume

TextAlign

Right

Textbox3

Name

Txt_tinggi

 

TextAlign

Right

Button1

Name

Btn_hitung

Text

Hitung

Button2

Name

Btn_batal

Text

Batal

Button 3

Name

Btn_keluar

text

Keluar


Untuk codinganya, bisa copy dibawah ini : 

Public Class FormLuasKerucut

    Private Sub btn_hitung_Click(sender As Object, e As EventArgs) Handles btn_hitung.Click
        Dim r As Double, phi As Decimal

        phi = 3.14
        r = Val(txt_jari.Text)

        If txt_jari.Text = "" Then
            MsgBox("informasi tidak lengkap", vbInformation, "Kerucut")

        Else
            txt_volume.Text = 1 / 3 * phi * (r ^ 2) * txt_tinggi.Text
            txt_jari.Text = r

        End If
    End Sub

    Private Sub FormLuasKerucut_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        txt_volume.Enabled = False
    End Sub

    Private Sub btn_batal_Click(sender As Object, e As EventArgs) Handles btn_batal.Click
        txt_jari.Clear()
        txt_tinggi.Clear()
        txt_volume.Clear()
        txt_jari.Focus()
    End Sub

    Private Sub btn_keluar_Click(sender As Object, e As EventArgs) Handles btn_keluar.Click
        Me.Close()
    End Sub
End Class


Demikianlah, contoh program sederhana via dekstop vb.net semoga bermanfaat :)


Komentar

Postingan populer dari blog ini

Cara Mudah Membuat Relasi Database Menggunakan Sql Server