Pages

Rabu, 30 Maret 2011

Membuat program data base tanpa koneksi database (hanya tampilan)

1. langkah yang pertama buat Design seperti berikut :


2.buat scribnya seperti berikut :
Public Class Form1

    Dim listitem As ListViewItem
    Dim listtxt(4) As String
    Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
        Call bersih()
    End Sub
    Sub bersih()
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        listtxt(0) = Trim(TextBox1.Text)
        listtxt(1) = Trim(TextBox2.Text)
        listtxt(2) = Trim(TextBox3.Text)
        listtxt(3) = Trim(TextBox4.Text)
        'untuk memasukkan ke listview dari variable
        listitem = New ListViewItem(listtxt)
        ListView1.Items.Add(listitem)

    End Sub
    Sub setlistview()
        ListView1.View = View.Details
        'untuk menentukan kolom
        ListView1.Columns.Add("Kode barang", 100, HorizontalAlignment.Center)
        ListView1.Columns.Add("Describtion", 130, HorizontalAlignment.Left)
        ListView1.Columns.Add("Spesifikasi", 150, HorizontalAlignment.Left)
        ListView1.Columns.Add("nomer mould", 100, HorizontalAlignment.Left)
    End Sub


    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        If Button5.Text = "close" Then
            Me.Close() 'me untuk menutup form diri sendiri
        Else
            Call bersih()
            Call normal()
        End If
    End Sub
    Sub normal()
        Button1.Text = "save"
        Button1.Enabled = True
        Button2.Text = "edit"
        Button2.Enabled = True
        Button3.Text = "delete"
        Button3.Enabled = True
        Button4.Text = "cancel"
        Button4.Enabled = True
        Button5.Text = "close"
        Button5.Enabled = True
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Button2.Text = "edit" Then
            Button2.Text = "ubah"
            Button1.Enabled = False
            Button3.Enabled = False
            Button4.Enabled = False
            Button5.Text = "keluar"
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If Button3.Text = "delete" Then
            Button3.Text = "hapus"
            Button1.Enabled = False
            Button2.Enabled = False
            Button4.Enabled = False
            Button5.Text = "keluar"
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If Button4.Text = "cancel" Then
            Button4.Text = "tunda"
            Button1.Enabled = False
            Button2.Enabled = False
            Button3.Enabled = False
            Button5.Text = "keluar"
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Call setlistview()
    End Sub
End Class
 
3.maka setelah dijalankan hasilnya akan seperti berikut :

0 komentar:

Posting Komentar