Minggu, 07 Juni 2015

UAS LAB VB





 




Source Coding: 

Form1
Public Class Form1

    Private Sub BtnVisit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnVisit.Click
        Form3.Show()
        Me.Hide()
    End Sub

    Private Sub BtnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnLogin.Click
        If TextBox1.Text = "ghassannim" And TextBox2.Text = "1406629433" Then
            Form2.Show()
            Me.Hide()
        ElseIf MsgBox("Incorrect username or password", MsgBoxStyle.Critical, "Warning!") Then
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox1.Focus()
        End If
    End Sub
End Class

Form2
Public Class Form2

    Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
        Label5.Text = DateAndTime.Now
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim a As String

        a = ComboBox1.Text

        If a = "Provokasi Hitam" Then
            PictureBox1.Image = System.Drawing.Image.FromFile("D:\Downloads\212667.jpg")
        ElseIf a = "Provokasi Abu-abu" Then
            PictureBox1.Image = System.Drawing.Image.FromFile("D:\Downloads\212666.jpg")
        ElseIf a = "Spartan" Then
            PictureBox1.Image = System.Drawing.Image.FromFile("D:\Downloads\KAOS SPARTAN DEPAN 1.jpg")
        End If
    End Sub


    Private Sub Form2_activated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Activated
        On Error Resume Next
        Dim var3 As Object
        Dim var2 As Object
        Dim var1 As Object
        Dim noFile As Short
        noFile = FreeFile()
        FileOpen(noFile, "D:\Documents\MASYI\Visual Studio 2008\Projects\PROVOKshop\listbox.TXT", OpenMode.Input)
        Do While Not EOF(noFile)
            Input(1, var1)
            Input(1, var2)
            Input(1, var3)
            ListBox1.Items.Add(var1 & " " & var2 & " " & var3 & " ")
        Loop
        FileClose(noFile)
    End Sub

    Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click
        On Error Resume Next

        SaveFileDialog1.Filter = "Text File|*.txt|CSV File|*.CSV"
        SaveFileDialog1.DefaultExt = "*.txt"
        SaveFileDialog1.ShowDialog()
    End Sub

    Private Sub ExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub BtnProses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnProses.Click
        MessageBox.Show("Total Pembelian Anda Rp 80.000. Terimakasih atas pemesanannya :)")
    End Sub
End Class

Form3
Public Class Form3

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form1.Show()
        Me.Hide()

    End Sub
End Class