Jumat, 10 Januari 2014

“Control Object” dengan Visual Basic.NET 2010

Toko Komputer

Contoh penerapan “App.Path” dan “LoadPicture” yang sering dipergunakan pada Visual Basic 6.0 yang pada fersi-fersi awal sampai dengan terbaru Visual Basic.NET perintah ini ditiadakan.

 


 

Layout Toko Komputer

Public Class Form1
    Dim FILE_NAME As String = Application.StartupPath & "\Image\"

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim strPeralatan As String() = {"Backup Disk", "Printer", "Parabola"}
        Dim strMetodeBayar As String() = {"Dollar Amerika", "Cek", "Kontan Rupiah"}

        ListBox1.Items.AddRange(strPeralatan)
        ComboBox1.Items.AddRange(strMetodeBayar)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Close()
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        If System.IO.File.Exists(FILE_NAME & "PCOMPUTR.WMF") = True Then
            Dim LoadPicture As New Bitmap(FILE_NAME & "PCOMPUTR.WMF")
            PictureBox1.Image = LoadPicture
            PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
        Else
            MsgBox("File Does Not Exist")
        End If
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        If System.IO.File.Exists(FILE_NAME & "COMPUTER.WMF") = True Then
            Dim LoadPicture As New Bitmap(FILE_NAME & "COMPUTER.WMF")
            PictureBox1.Image = LoadPicture
            PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
        Else
            MsgBox("File Does Not Exist")
        End If
    End Sub

    Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged
        If System.IO.File.Exists(FILE_NAME & "LAPTOP1.WMF") = True Then
            Dim LoadPicture As New Bitmap(FILE_NAME & "LAPTOP1.WMF")
            PictureBox1.Image = LoadPicture
            PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
        Else
            MsgBox("File Does Not Exist")
        End If
    End Sub

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
        If System.IO.File.Exists(FILE_NAME & "ANSWMACH.WMF") = True Then
            Dim LoadPicture As New Bitmap(FILE_NAME & "ANSWMACH.WMF")
            PictureBox2.Image = LoadPicture
            PictureBox2.SizeMode = PictureBoxSizeMode.StretchImage
        Else
            MsgBox("File Does Not Exist")
        End If
    End Sub

    Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
        If System.IO.File.Exists(FILE_NAME & "CALCULTR.WMF") = True Then
            Dim LoadPicture As New Bitmap(FILE_NAME & "CALCULTR.WMF")
            PictureBox3.Image = LoadPicture
            PictureBox3.SizeMode = PictureBoxSizeMode.StretchImage
        Else
            MsgBox("File Does Not Exist")
        End If
    End Sub

    Private Sub CheckBox3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox3.CheckedChanged
        If System.IO.File.Exists(FILE_NAME & "COPYMACH.WMF") = True Then
            Dim LoadPicture As New Bitmap(FILE_NAME & "COPYMACH.WMF")
            PictureBox5.Image = LoadPicture
            PictureBox5.SizeMode = PictureBoxSizeMode.StretchImage
        Else
            MsgBox("File Does Not Exist")
        End If
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        Select Case ListBox1.SelectedIndex
            Case 0
                If System.IO.File.Exists(FILE_NAME & "HARDDISK.WMF") = True Then
                    Dim LoadPicture As New Bitmap(FILE_NAME & "HARDDISK.WMF")
                    PictureBox4.Image = LoadPicture
                    PictureBox4.SizeMode = PictureBoxSizeMode.StretchImage
                Else
                    MsgBox("File Does Not Exist")
                End If
            Case 1
                If System.IO.File.Exists(FILE_NAME & "PRINTER.WMF") = True Then
                    Dim LoadPicture As New Bitmap(FILE_NAME & "PRINTER.WMF")
                    PictureBox4.Image = LoadPicture
                    PictureBox4.SizeMode = PictureBoxSizeMode.StretchImage
                Else
                    MsgBox("File Does Not Exist")
                End If
            Case 2
                If System.IO.File.Exists(FILE_NAME & "SATEDISH.WMF") = True Then
                    Dim LoadPicture As New Bitmap(FILE_NAME & "SATEDISH.WMF")
                    PictureBox4.Image = LoadPicture
                    PictureBox4.SizeMode = PictureBoxSizeMode.StretchImage
                Else
                    MsgBox("File Does Not Exist")
                End If
        End Select
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Select Case ComboBox1.SelectedIndex
            Case 0
                If System.IO.File.Exists(FILE_NAME & "DOLLAR.WMF") = True Then
                    Dim LoadPicture As New Bitmap(FILE_NAME & "DOLLAR.WMF")
                    PictureBox6.Image = LoadPicture
                    PictureBox6.SizeMode = PictureBoxSizeMode.StretchImage
                Else
                    MsgBox("File Does Not Exist")
                End If
            Case 1
                If System.IO.File.Exists(FILE_NAME & "CHECK.WMF") = True Then
                    Dim LoadPicture As New Bitmap(FILE_NAME & "CHECK.WMF")
                    PictureBox6.Image = LoadPicture
                    PictureBox6.SizeMode = PictureBoxSizeMode.StretchImage
                Else
                    MsgBox("File Does Not Exist")
                End If
            Case 2
                If System.IO.File.Exists(FILE_NAME & "RUBLE.WMF") = True Then
                    Dim LoadPicture As New Bitmap(FILE_NAME & "RUBLE.WMF")
                    PictureBox6.Image = LoadPicture
                    PictureBox6.SizeMode = PictureBoxSizeMode.StretchImage
                Else
                    MsgBox("File Does Not Exist")
                End If
        End Select
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        If MsgBox("Exit the Aplication?", vbYesNo + vbQuestion, "Confirmation") = vbNo Then
            If e.CloseReason = CloseReason.UserClosing Then
                e.Cancel = True
            End If
        End If
    End Sub
End Class

Label:

0 Komentar:

Posting Komentar

Berlangganan Posting Komentar [Atom]

<< Beranda