Rabu, 08 Juni 2011




Imports System.Data
Imports System.Data.Sql
Module koneksi
Public database As New OleDb.OleDbConnection
Public tampil2 As New OleDb.OleDbCommand
Public tampilkan As OleDb.OleDbDataReader
Public hasilcek As String

Public Sub bukakoneksi()
database.Close()
Try
database.ConnectionString = "provider=sqloledb.1;integrated security=SSPI;persist security info=false; initial catalog=cobasql;data source=."
database.Open()
MessageBox.Show("Koneksi kedatabase berhasil")
Catch ex As Exception
MessageBox.Show("koneksi gagal")

End

End Try


End Sub


End Module



Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
If UsernameTextBox.Text = "sep" And PasswordTextBox.Text = "123" Then
MDIParent1.Show()
Hide()

Else
MsgBox(" Kode yang anda masukkan Salah")

End If

End Sub

Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
End
Me.Close()
End Sub

End Class

Kamis, 31 Maret 2011

Contoh VB4

Contoh VB4


Scrip
Public Class Form1
'Membuat variable array'
Dim listtxt(3) As String
Dim listitem As ListViewItem

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Masukkan nilai ke variable aray'
listtxt(0) = Trim(TextBox1.Text)
listtxt(1) = Trim(TextBox2.Text)
listtxt(2) = Trim(TextBox3.Text)

'Untuk memasukkan ke listview dari variable'
listitem = New ListViewItem(listtxt)
ListView1.items.Add(listitem)
End Sub
'Setting Kolom list view
Sub setlistview()

ListView1.View = View.Details

'Untuk menampilkan kolom
ListView1.Columns.Add("NPM", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Nama", 100, HorizontalAlignment.Left)
ListView1.Columns.Add("Alamat", 100, HorizontalAlignment.Right)
End Sub


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call setlistview()
End Sub

Private Sub ListView1_ItemSelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles ListView1.ItemSelectionChanged
TextBox4.Text = e.Item.Text
End Sub
End Class