riyana's blog: Visual Basic App
Hello Kitty Pink Cherry

Minggu, 14 Oktober 2012

Visual Basic App

Aplikasi yang saya buat adalah aplikasi konversi ukuran atau perubahan ukuran. Misal ukuran dari kilometer ke meter dan sebaliknya, serta dari meter ke desimeter dan sebaliknya.
Tujuan membuat aplikasi ini yaitu untuk memenuhi tugas yang diberikan oleh Bapak Nandang Hermanto.
Adapun komponen yang saya pakai antara lain :
1. Form
2. Label
3. TextBox
4. Button
5. RadioButton

Di bawah ini adalah syntac dari aplikasi di atas

Public Class Ukuran



    Dim Change As Double = 0

    Private Sub rdbt2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdbt2.CheckedChanged
        lbluk1.Text = "Meter"
        lbluk2.Text = "Kilometer"
        txt1.Focus()
        Change = 1.0 / 1000.0
    End Sub
    Private Sub rdbt1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdbt1.CheckedChanged
        lbluk1.Text = "Kilometer"
        lbluk2.Text = "Meter"
        txt1.Focus()
        Change = 1000.0
    End Sub
  
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub rdbt3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdbt3.CheckedChanged
        lbluk1.Text = "Meter"
        lbluk2.Text = "Desimeter"
        txt1.Focus()
        Change = 10.0
    End Sub

    Private Sub rdbt4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rdbt4.CheckedChanged
        lbluk1.Text = "Desimeter"
        lbluk2.Text = "Meter"
        txt1.Focus()
        Change = 1.0 / 10.0
    End Sub

    Private Sub bt1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt1.Click
        Dim awal_bgt As Double
        Dim hasil As Double

        Try
            awal_bgt = Convert.ToDouble(txt1.Text)
        Catch ex As Exception
            awal_bgt = 0
            MsgBox("Anda tidak benar menginputkannya", MsgBoxStyle.Critical, "Peringatan")
        End Try

        hasil = awal_bgt * Change

        txt2.Text = hasil
    End Sub

    Private Sub bt2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt2.Click
        txt1.Clear()
        txt2.Clear()
        txt1.Focus()

    End Sub

    Private Sub bt3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt3.Click
        If MsgBox("Are you sure want to quit this application now?", vbYesNo + vbQuestion + vbDefaultButton2, "Konfirmasi") = vbYes Then
            End
        End If

    End Sub
End Class

2 komentar: