Coba-coba
imam reza
Imamrazali.blogspot.com
Total Tayangan Halaman
Sabtu, 11 Februari 2012
Minggu, 29 Januari 2012
Postingan Soal No (Imam RazaliJawaban no 3 (Imam Razali))
Untuk Kasus Lihat disini KASUS
Listing Program
Dim ClientIndex As Byte
Dim cRequest As Integer
Dim cData As String
Dim i As Integer
Dim iGD As Integer
Sub MulaiServer()
WS(0).LocalPort = 3000
WS(0).Listen
cRequest = 1
ClientIndex = 1
End Sub
Private Sub Form_Load()
MulaiServer
GD.Rows = 41
For i = 1 To 40
GD.Col = 0
GD.Row = i
GD.Text = i
Next i
iGD = 1
End Sub
Private Sub Timer1_Timer()
For i = 1 To GD.Rows - 1
GD.Row = i
GD.Col = 4
If GD.Text = "START" Then
GD.Col = 3
GD.Text = Time
End If
Next i
End Sub
Private Sub Timer2_Timer()
WS.SendData "PAKAI-" & Pakai.Value & "/" & 3000
End Sub
Private Sub WS_ConnectionRequest(index As Integer, ByVal requestID As Long)
Load WS(cRequest)
WS(cRequest).Close
WS(cRequest).Accept requestID
cRequest = cRequest + 1 '
Timer1.Enabled = True
Timer2.Enabled = True
End Sub
Private Sub WS_DataArrival(index As Integer, ByVal bytesTotal As Long)
WS(index).GetData cData, vbString, bytesTotal
Call CekData(index)
End Sub
Sub CekData(index)
Dim kata() As String
kata = Split(cData, "-")
Select Case kata(0)
Case "START"
GD.Row = iGD
GD.Col = 1
GD.Text = kata(1) 'WS(index).RemoteHostIP
GD.Col = 2
GD.Text = Time
GD.Col = 4
GD.Text = "START"
GD.Col = 5
GD.Text = kata(2)
iGD = iGD
Case "STOP"
For i = 1 To GD.Rows - 1
GD.Row = i
GD.Col = 1
If GD.Text = kata(1) Then
GD.Col = 4
GD.Text = "STOP"
End If
Next i
End Select
End Sub
Private Sub WS_Error(index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
WS(index).Close
End Sub
Dim IPS As String
Dim User As String
Private Sub Command1_Click()
WS.SendData "START-" & User & "-Putri Kartika Sari"
End Sub
Private Sub Command2_Click()
WS.SendData "STOP-" & User
End Sub
Private Sub Form_Load()
IPS = "127.0.0.1"
User = WS.LocalIP
WS.Connect IPS, 3000
End Sub
Private Sub WS_DataArrival(ByVal bytesTotal As Long)
WS.GetData xKirim, vbString, bytesTotal
Call CheckData
End Sub
Sub CheckData()
xdata1 = Split(xKirim, "-")
xdata2 = Split(xdata1(1), "/")
Select Case xdata1(0)
Case "PAKAI"
mulai.Value = xdata2(0)
selesai.Value = xdata2(1)
pakai.Value = xdata2(2)
biaya.Text = (Val(Hour(pakai.Value) * 60) + Val(Minute(pakai.Value) * 50))
End Select
Untuk Kasus Lihat disini KASUS
Listing Program
PROGRAM SERVER
Dim ClientIndex As Byte
Dim cRequest As Integer
Dim cData As String
Dim i As Integer
Dim iGD As Integer
Sub MulaiServer()
WS(0).LocalPort = 3000
WS(0).Listen
cRequest = 1
ClientIndex = 1
End Sub
Private Sub Form_Load()
MulaiServer
GD.Rows = 41
For i = 1 To 40
GD.Col = 0
GD.Row = i
GD.Text = i
Next i
iGD = 1
End Sub
Private Sub Timer1_Timer()
For i = 1 To GD.Rows - 1
GD.Row = i
GD.Col = 4
If GD.Text = "START" Then
GD.Col = 3
GD.Text = Time
End If
Next i
End Sub
Private Sub Timer2_Timer()
WS.SendData "PAKAI-" & Pakai.Value & "/" & 3000
End Sub
Private Sub WS_ConnectionRequest(index As Integer, ByVal requestID As Long)
Load WS(cRequest)
WS(cRequest).Close
WS(cRequest).Accept requestID
cRequest = cRequest + 1 '
Timer1.Enabled = True
Timer2.Enabled = True
End Sub
Private Sub WS_DataArrival(index As Integer, ByVal bytesTotal As Long)
WS(index).GetData cData, vbString, bytesTotal
Call CekData(index)
End Sub
Sub CekData(index)
Dim kata() As String
kata = Split(cData, "-")
Select Case kata(0)
Case "START"
GD.Row = iGD
GD.Col = 1
GD.Text = kata(1) 'WS(index).RemoteHostIP
GD.Col = 2
GD.Text = Time
GD.Col = 4
GD.Text = "START"
GD.Col = 5
GD.Text = kata(2)
iGD = iGD
Case "STOP"
For i = 1 To GD.Rows - 1
GD.Row = i
GD.Col = 1
If GD.Text = kata(1) Then
GD.Col = 4
GD.Text = "STOP"
End If
Next i
End Select
End Sub
Private Sub WS_Error(index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
WS(index).Close
End Sub
PROGRAM CLIENT
Dim IPS As String
Dim User As String
Private Sub Command1_Click()
WS.SendData "START-" & User & "-Putri Kartika Sari"
End Sub
Private Sub Command2_Click()
WS.SendData "STOP-" & User
End Sub
Private Sub Form_Load()
IPS = "127.0.0.1"
User = WS.LocalIP
WS.Connect IPS, 3000
End Sub
Private Sub WS_DataArrival(ByVal bytesTotal As Long)
WS.GetData xKirim, vbString, bytesTotal
Call CheckData
End Sub
Sub CheckData()
xdata1 = Split(xKirim, "-")
xdata2 = Split(xdata1(1), "/")
Select Case xdata1(0)
Case "PAKAI"
mulai.Value = xdata2(0)
selesai.Value = xdata2(1)
pakai.Value = xdata2(2)
biaya.Text = (Val(Hour(pakai.Value) * 60) + Val(Minute(pakai.Value) * 50))
End Select
Quis Online No.2
Postingan Jawaban No.2 (Putri Kartika Sari)Untuk Kasus Lihat disini KASUS
Listing Program
SERVER
MODULE
Public db As New ADODB.Connection
Public rs As New ADODB.Recordset
Public rs2 As New ADODB.Recordset
Public SQL As String
Sub opendb()
If db.State = adStateOpen Then db.Close
db.CursorLocation = adUseClient
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Sony\My Documents\belajar server\test2.mdb;Persist Security Info=False"
End Sub
Sub clearform(f As Form)
Dim ctl As Control
For Each ctl In f
If TypeOf ctl Is TextBox Then ctl.Text = ""
If TypeOf ctl Is ComboBox Then ctl.Text = ""
Next
End Sub
Sub center(f As Form)
f.Move (Screen.Width - f.Width) / 2, (Screen.Height - f.Height) / 4
End Sub
Sub rubahcmd(f As Form, L0 As Boolean, L1 As Boolean, L2 As Boolean, L3 As Boolean)
f.cmdproses(0).Enabled = L0
f.cmdproses(1).Enabled = L1
f.cmdproses(2).Enabled = L2
f.cmdproses(3).Enabled = L3
End Sub
LISTING PROGRAM SERVER
Private Sub cmdproses_Click(Index As Integer)
Select Case Index
Case 0
Call hapus
kode.SetFocus
Case 1
If cmdproses(1).Caption = "&Simpan" Then
Call prosesDB(0)
Else
Call prosesDB(1)
End If
Case 2
X = MsgBox("yakin RECORD barang akan dihapus...!", vbQuestion + vbYesNo, "barang")
If X = vbYes Then prosesDB 2
Call hapus
kode.SetFocus
Case 3
Call hapus
kode.SetFocus
Case 4
Unload Me
End Select
End Sub
Sub hapus()
kode.Enabled = True
clearform Me
Call rubahcmd(Me, True, False, False, False)
cmdproses(1).Caption = " &Simpan"
End Sub
Private Sub Form_Load()
Call opendb
Call hapus
mulaiserver
End Sub
Sub prosesDB(log As Byte)
Select Case log
Case 0
SQL = "INSERT INTO barang(kode,nama,harga)" & _
"values('" & kode.Text & _
"','" & nama.Text & _
"','" & harga.Text & "')"
Case 1
SQL = "UPDATE barang SET nama='" & nama.Text & "'," & _
"harga='" & harga.Text & "' " & _
"WHERE kode='" & kode.Text & "'"
Case 2
SQL = "DELETE FROM barang WHERE kode='" & kode.Text & "'"
End Select
MsgBox "Pemrosesan record Database telah berhasil....!!", vbInformation, "Data Barang"
db.BeginTrans
db.Execute SQL, adCmdTable
db.CommitTrans
Call hapus
Adodc1.Refresh
kode.SetFocus
End Sub
Sub tampilbarang()
On Error Resume Next
kode.Text = rs!kode
nama.Text = rs!nama
harga.Text = rs!harga
End Sub
Private Sub kode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If kode.Text = "" Then
MsgBox "Masukkan Kode Barang!", vbInformation, "Barang"
kode.SetFocus
Exit Sub
End If
SQL = " SELECT * FROM barang WHERE kode='" & kode.Text & "'"
If rs.State = adStateOpen Then rs.Close
rs.Open SQL, db, adOpenDynamic, adLockOptimistic
If rs.RecordCount <> 0 Then
tampilbarang
Call rubahcmd(Me, False, True, True, True)
cmdproses(1).Caption = "&Edit"
kode.Enabled = False
Else
X = kode.Text
Call hapus
kode.Text = X
Call rubahcmd(Me, False, True, False, True)
cmdproses(1).Caption = "&Simpan"
End If
nama.SetFocus
End If
End Sub
Sub mulaiserver()
ws.LocalPort = 1000
ws.Listen
End Sub
Private Sub ws_ConnectionRequest(ByVal requestID As Long)
ws.Close
ws.Accept requestID
Me.Caption = "server-client" & ws.RemoteHostIP & "connect"
End Sub
Private Sub ws_DataArrival(ByVal bytesTotal As Long)
Dim xkirim As String
Dim xData1() As String
Dim xData2() As String
ws.GetData xkirim, vbString, bytesTotal
xData1 = Split(xkirim, "-")
Select Case xData1(0)
Case "SEARCH"
SQL = " delete * FROM barang " & _
" where kode= '" & xData1(1) & "'"
SQL = "SELECT * FROM barang WHERE kode='" & xData1(1) & "'"
If rs.State = adStateOpen Then rs.Close
rs.Open SQL, db, adOpenDynamic, adLockOptimistic
If rs.RecordCount <> 0 Then
ws.SendData "RECORD-" & rs!nama & "/" & rs!harga
Else
ws.SendData "NOTHING-DATA"
End If
Case "INSERT"
Case "EDIT"
Case "DELETE"
SQL = " delete * FROM barang " & _
" where kode= '" & xData1(1) & "'"
db.BeginTrans
db.Execute SQL, adCmdTable
db.CommitTrans
Adodc1.Refresh
ws.SendData "DEL-xxx"
Case "UPDATE"
db.BeginTrans
db.Execute xData1(1), adCmdTable
db.CommitTrans
End Select
End Sub
Hasil Program
CLIENT
MODULE
Public db As New ADODB.Connection
Public rs As New ADODB.Recordset
Public rs2 As New ADODB.Recordset
Public SQL As String
Sub opendb()
If db.State = adStateOpen Then db.Close
db.CursorLocation = adUseClient
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\Sriwahyu-a562c3\vb2\vb\test.mdb;Persist Security Info=False"
End Sub
Sub clearform(f As Form)
Dim ctl As Control
For Each ctl In f
If TypeOf ctl Is TextBox Then ctl.Text = ""
If TypeOf ctl Is ComboBox Then ctl.Text = ""
Next
End Sub
Sub center(f As Form)
f.Move (Screen.Width - f.Width) / 2, (Screen.Height - f.Height) / 4
End Sub
Sub rubahcmd(f As Form, L0 As Boolean, L1 As Boolean, L2 As Boolean, L3 As Boolean)
f.cmdproses(0).Enabled = L0
f.cmdproses(1).Enabled = L1
f.cmdproses(2).Enabled = L2
f.cmdproses(3).Enabled = L3
End Sub
LISTING PROGRAM SERVER
Private Sub cmdproses_Click(Index As Integer)
Select Case Index
Case 0
Call hapus
kode.SetFocus
Case 1
If cmdproses(1).Caption = "&Simpan" Then
Call prosesDB(0)
Else
Call prosesDB(1)
End If
Case 2
X = MsgBox("yakin RECORD barang akan dihapus...!", vbQuestion + vbYesNo, "barang")
If X = vbYes Then prosesDB 2
Call hapus
kode.SetFocus
Case 3
Call hapus
kode.SetFocus
Case 4
Unload Me
End Select
End Sub
Sub hapus()
kode.Enabled = True
clearform Me
Call rubahcmd(Me, True, False, False, False)
cmdproses(1).Caption = " &Simpan"
End Sub
Private Sub Form_Load()
Call opendb
Call hapus
mulaiserver
End Sub
Sub prosesDB(log As Byte)
Select Case log
Case 0
SQL = "INSERT INTO barang(kode,nama,harga)" & _
"values('" & kode.Text & _
"','" & nama.Text & _
"','" & harga.Text & "')"
Case 1
SQL = "UPDATE barang SET nama='" & nama.Text & "'," & _
"harga='" & harga.Text & "' " & _
"WHERE kode='" & kode.Text & "'"
Case 2
SQL = "DELETE FROM barang WHERE kode='" & kode.Text & "'"
End Select
MsgBox "Pemrosesan record Database telah berhasil....!!", vbInformation, "Data Barang"
db.BeginTrans
db.Execute SQL, adCmdTable
db.CommitTrans
Call hapus
Adodc1.Refresh
kode.SetFocus
End Sub
Sub tampilbarang()
On Error Resume Next
kode.Text = rs!kode
nama.Text = rs!nama
harga.Text = rs!harga
End Sub
Private Sub kode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If kode.Text = "" Then
MsgBox "Masukkan Kode Barang!", vbInformation, "Barang"
kode.SetFocus
Exit Sub
End If
SQL = " SELECT * FROM barang WHERE kode='" & kode.Text & "'"
If rs.State = adStateOpen Then rs.Close
rs.Open SQL, db, adOpenDynamic, adLockOptimistic
If rs.RecordCount <> 0 Then
tampilbarang
Call rubahcmd(Me, False, True, True, True)
cmdproses(1).Caption = "&Edit"
kode.Enabled = False
Else
X = kode.Text
Call hapus
kode.Text = X
Call rubahcmd(Me, False, True, False, True)
cmdproses(1).Caption = "&Simpan"
End If
nama.SetFocus
End If
End Sub
Sub mulaiserver()
ws.LocalPort = 1000
ws.Listen
End Sub
Private Sub ws_ConnectionRequest(ByVal requestID As Long)
ws.Close
ws.Accept requestID
Me.Caption = "server-client" & ws.RemoteHostIP & "connect"
End Sub
Private Sub ws_DataArrival(ByVal bytesTotal As Long)
Dim xkirim As String
Dim xData1() As String
Dim xData2() As String
ws.GetData xkirim, vbString, bytesTotal
xData1 = Split(xkirim, "-")
Select Case xData1(0)
Case "SEARCH"
SQL = " delete * FROM barang " & _
" where kode= '" & xData1(1) & "'"
SQL = "SELECT * FROM barang WHERE kode='" & xData1(1) & "'"
If rs.State = adStateOpen Then rs.Close
rs.Open SQL, db, adOpenDynamic, adLockOptimistic
If rs.RecordCount <> 0 Then
ws.SendData "RECORD-" & rs!nama & "/" & rs!harga
Else
ws.SendData "NOTHING-DATA"
End If
Case "INSERT"
Case "EDIT"
Case "DELETE"
SQL = " delete * FROM barang " & _
" where kode= '" & xData1(1) & "'"
db.BeginTrans
db.Execute SQL, adCmdTable
db.CommitTrans
Adodc1.Refresh
ws.SendData "DEL-xxx"
Case "UPDATE"
db.BeginTrans
db.Execute xData1(1), adCmdTable
db.CommitTrans
End SelectEnd Sub
Hasil Program
Sabtu, 28 Januari 2012
Belajar Server
1. Pengertian jaringan Client – Server
Server adalah komputer yang menyediakan fasilitas bagi komputer- komputer lain di dalam jaringan
client adalah komputer-komputer yang menerima atau menggunakan fasilitas yang disediakan oleh server.
Server di jaringan tipe client-server disebut dengan Dedicated Server karena murni berperan sebagai server yang menyediakan fasilitas kepada workstation dan server tersebut tidak dapat berperan sebagai workstation.
2. Program server
Langkah - langkah pembuatan program server yang menggunakan program Microsoft Office Acces 2003 dan program Microsoft Visual Basic 6.0 yaitu :
a. Rancanglah pembuatan data base pada program Microsoft Office Acces 2003.
Nama database : Laporan data pengawai
Nama table : Data
Start, program, pilih Microsoft Office Acces 2003. Pada sebelah kanan bawah tampilan terdapat icon – icon. Klik create a new file. Ketik blank database. Lalu ketik nama database Mahasiswa dengan nama tabel data. Double klik table data isilah field name dan data typenya. Seperti tampilan dibawah ini.
b. Start, program, pilih Microsoft Visual Basic 6.0, Microsoft Visual Basic 6.0, standard Exe, klik Openc. Rancang tampilan pada Form Login.
Ketik listing program pada form login.
Private Sub Command1_Click()
If user.Text = "lindawati" And password.Text = "0902146" Then
MDIForm1.Show
ElseIf user.Text = "" & password.Text = "" Then
MsgBox "Silahkan masukkan password login", vbCritical, "info"
user.SetFocus
Else
MsgBox "Password yang anda inputkan salah", vbCritical, "info"
user.Text = ""
password.Text = ""
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
user.Text = ""
password.Text = ""
password.PasswordChar = "*"
End Sub
d. Rancang tampilan pada Form MDIForm1
Ketik listing program pada form MDIForm1.
Private Sub e_Click()
Unload Me
End Sub
Private Sub ldm_Click()
datapegawai.Show
End Sub
Private Sub MDIForm_Load()
End Sub
Rancang tampilan seperti tampilan dibawah ini dengan menggunakan Microsoft Visual Basic 6.0.
e. Ketik listing program pada Form1.
Private Sub cmdproses_Click(Index As Integer)
Select Case Index
Case 0
Call hapus
nip.SetFocus
Case 1
If cmdproses(1).Caption = "&Simpan" Then
Call prosesDB(0)
Else
Call prosesDB(1)
End If
Case 2
X = MsgBox("yakin RECORD data akan dihapus...!", vbQuestion + vbYesNo, "data")
If X = vbYes Then prosesDB 2
Call hapus
nip.SetFocus
Case 3
Call hapus
nip.SetFocus
Case 4
Unload Me
End Select
End Sub
Sub hapus()
nip.Enabled = True
clearform Me
Call rubahcmd(Me, True, False, False, False)
cmdproses(1).Caption = " &Simpan"
End Sub
Private Sub Form_Load()
Call opendb
Call hapus
mulaiserver
End Sub
Sub prosesDB(log As Byte)
Select Case log
Case 0
SQL = "INSERT INTO data(nip,nama,Golongan,alamat)" & _
"values('" & nip.Text & _
"','" & nama.Text & _
"','" & Golongan.Text & _
"','" & alamat.Text & "')"
Case 1
SQL = "UPDATE data SET nama='" & nama.Text & "'," & _
"Golongan='" & Golongan.Text & "' " & _
"alamat='" & alamat.Text & "' " & _
"WHERE nip='" & nip.Text & "'"
Case 2
SQL = "DELETE FROM data WHERE nip='" & nip.Text & "'"
End Select
MsgBox "Pemrosesan record Database telah berhasil....!!", vbInformation, "data"
db.BeginTrans
db.Execute SQL, adCmdTable
db.CommitTrans
Call hapus
Adodc1.Refresh
nip.SetFocus
End Sub
Sub tampildata()
On Error Resume Next
nip.Text = rs!nip
nama.Text = rs!nama
Golongan.Text = rs!Golongan
alamat.Text = rs!alamat
End Sub
Sub mulaiserver()
ws.LocalPort = 1000
ws.Listen
End Sub
Private Sub nip_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If nip.Text = "" Then
MsgBox "Masukkan nip!", vbInformation, "data"
nip.SetFocus
Exit Sub
End If
SQL = " SELECT * FROM data WHERE nip='" & nip.Text & "'"
If rs.State = adStateOpen Then rs.Close
rs.Open SQL, db, adOpenDynamic, adLockOptimistic
If rs.RecordCount <> 0 Then
tampildata
Call rubahcmd(Me, False, True, True, True)
cmdproses(1).Caption = "&Edit"
nip.Enabled = False
Else
X = nip.Text
Call hapus
nip.Text = X
Call rubahcmd(Me, False, True, False, True)
cmdproses(1).Caption = "&Simpan"
End If
nip.SetFocus
End If
End Sub
Private Sub ws_ConnectionRequest(ByVal requestID As Long)
ws.Close
ws.Accept requestID
Me.Caption = "server-client" & ws.RemoteHostIP & "connect"
End Sub
Private Sub ws_DataArrival(ByVal bytesTotal As Long)
Dim xkirim As String
Dim xData1() As String
Dim xData2() As String
ws.GetData xkirim, vbString, bytesTotal
xData1 = Split(xkirim, "-")
Select Case xData1(0)
Case "SEARCH"
SQL = " delete * FROM data " & _
" where nip= '" & xData1(1) & "'"
SQL = "SELECT * FROM data WHERE nip='" & xData1(1) & "'"
If rs.State = adStateOpen Then rs.Close
rs.Open SQL, db, adOpenDynamic, adLockOptimistic
If rs.RecordCount <> 0 Then
ws.SendData "RECORD-" & rs!nama & "/" & rs!Golongan & "/" & rs!alamat
Else
ws.SendData "NOTHING-DATA"
End If
Case "INSERT"
db.BeginTrans
db.Execute xData1(1), adCmdTable
db.CommitTrans
Adodc1.Refresh
ws.SendData "INSERT-XXX"
Case "UPDATE"
db.BeginTrans
db.Execute xData1(1), adCmdTable
db.CommitTrans
Adodc1.Refresh
ws.SendData "UPDATE-XXX"
Case "DELETE"
SQL = " delete * FROM data " & _
" where nip= '" & xData1(1) & "'"
db.BeginTrans
db.Execute SQL, adCmdTable
db.CommitTrans
Adodc1.Refresh
ws.SendData "DEL-xxx"
End Select
End Sub
f. Ketik listing program pada Module.
Klik kanan pada Form1, pilih add, Module, open. Double klik pada tampilan Module, lalu ketikkan listing programnya.
Public db As New ADODB.Connection
Public rs As New ADODB.Recordset
Public rs2 As New ADODB.Recordset
Public SQL As String
Sub opendb()
If db.State = adStateOpen Then db.Close
db.CursorLocation = adUseClient db.Open”Provider=Microsoft.Jet.OLEDB.4.0;DataSource=C:\belajarserver\server\mahasiswa.md; Persist Security Info=False"
End Sub
Sub clearform(f As Form)
Dim ctl As Control
For Each ctl In f
If TypeOf ctl Is TextBox Then ctl.Text = ""
If TypeOf ctl Is ComboBox Then ctl.Text = ""
Next
End Sub
Sub center(f As Form)
f.Move (Screen.Width - f.Width) / 2, (Screen.Height - f.Height) / 4
End Sub
Sub rubahcmd(f As Form, L0 As Boolean, L1 As Boolean, L2 As Boolean, L3 As Boolean)
f.cmdproses(0).Enabled = L0
f.cmdproses(1).Enabled = L1
f.cmdproses(2).Enabled = L2
f.cmdproses(3).Enabled = L3
End Sub
Pada tool box tampilan rancangan program terdapat Project, pilih project1 properties, pada startup object, pilih login. Agar tampilan layar setelah di jalankan akan muncul form login terlebih dahulu.seperti gambar dibawah ini.
Sehingga tampilan setelah dimasukkan password akan tampil seperti di bawah ini
Lalu muncullah tampilan yang dapat mengasilkan output, seperti gambar ini
3. Program Client
Langkah - langkah pembuatan program client tidak pelu merancang database lagi, dikarenakan pada database sudah terdapat pada Server, yang akan terkoneksi ke program client. Jadi program client hanya menggunakan bahasa pemograman Microsoft Visual Basic 6.0 yaitu :
a. Start, program, pilih Microsoft Visual Basic 6.0, Microsoft Visual Basic 6.0, standard Exe, klik Open.
Ketik listing program pada form login.
Private Sub Command1_Click()
If user.Text = "linda" And password.Text = "blendunk" Then
MDIForm1.Show
ElseIf user.Text = "" & password.Text = "" Then
MsgBox "Silahkan masukkan password login", vbCritical, "info"
user.SetFocus
Else
MsgBox "password yang anda inputkan salah", vbCritical, "info"
user.Text = ""
password.Text = ""
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
user.Text = ""
password.Text = ""
password.PasswordChar = "*"
End Sub
Ketik listing program pada form MDIForm1.
Private Sub e_Click()
Unload Me
End Sub
Private Sub ldm_Click()
Form1.Show
End Sub
Selanjutnya Rancang tampilan seperti tampilan dibawah ini dengan menggunakan Microsoft Visual Basic 6.0.
Ketik listing program pada Form1.
Dim IpServer As String
Sub hapus()
nip.Enabled = True
ClearFORM Me
Call rubahCMD(Me, True, False, False, False)
cmdproses(1).Caption = "&Simpan"
End Sub
Sub prosesDB(log As Byte)
Select Case log
Case 0
SQL = "INSERT INTO data(nip,nama,gol,alamat)" & _
"values('" & nip.Text & _
"','" & nama.Text & _
"','" & gol.Text & _
"','" & alamat.Text & "')"
Case 1
SQL = "UPDATE data SET nama='" & nama.Text & "'," & _
"gol='" & gol.Text & "' " & _
"alamat='" & alamat.Text & "' " & _
"where nip='" & nip.Text & "'"
Case 2
SQL = "DELETE FROM data WHERE nip='" & nip.Text & "'"
End Select
MsgBox "pemrosesan RECORD database telah berhasil...!", vbInformation, "data"
Call hapus
nip.SetFocus
End Sub
Private Sub cmdproses_Click(Index As Integer)
Select Case Index
Case 0
Call hapus
nip.SetFocus
Case 1
If cmdproses(1).Caption = " &Simpan" Then
Else
SQL = "UPDATE data Set " & _
"nama = '" & nama.Text & _
"gol = '" & gol.Text & _
"' , alamat= '" & alamat.Text & _
"' where nip= '" & nip.Text & "'"
ws.SendData "UPDATE-" & SQL
End If
Case 2
X = MsgBox("yakin RECORD data akan dihapus...!", vbQuestion + vbYesNo, "data")
If X = vbYes Then
ws.SendData "DELETE-" & nip.Text
End If
Call hapus
nip.SetFocus
Case 3
Call hapus
nip.SetFocus
Case 4
Unload Me
End Select
End Sub
Private Sub Form_Load()
Call hapus
mulaikoneksi
End Sub
Sub mulaikoneksi()
IpServer = "192.168.10.1"
IPClient = ws.LocalIP
ws.Connect IpServer, 1000
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
DoEvents
End
End Sub
Private Sub nip_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If nip.Text = "" Then Exit Sub
ws.SendData "SEARCH-" & nip.Text
End If
End Sub
Private Sub ws_DataArrival(ByVal bytesTotal As Long)
Dim xkirim As String
Dim xdata1() As String
Dim xdata2() As String
ws.GetData xkirim, vbString, bytesTotal
xdata1 = Split(xkirim, "-")
Select Case xdata1(0)
Case "NOTHING"
X = nip.Text
Call hapus
nip.Text = X
Call rubahCMD(Me, False, True, False, True)
cmdproses(1).Caption = "&Simpan"
nama.SetFocus
Case "RECORD"
xdata2 = Split(xdata1(1), "/")
nip.Text = xdata2(0)
gol.Text = xdata2(1)
alamat.Text = xdata2(2)
Call rubahCMD(Me, False, True, True, True)
cmdproses(1).Caption = "&Edit"
nip.Enabled = False
nama.SetFocus
Case "DEL"
MsgBox "penghapusan data berhasil!"
Call hapus
Case "EDIT"
MsgBox "Pengeditan Record berhasil!"
Call hapus
End Select
End Sub
Pada tool box tampilan rancangan program terdapat Project, pilih project1 properties, pada startup object, pilih login. Agar tampilan layar setelah di jalankan akan muncul form login terlebih dahulu.seperti gambar dibawah ini.
Sehingga tampilan setelah dimasukkan password akan tampil seperti di bawah iniLalu muncullah tampilan yang dapat mengasilkan output, seperti gambar dibawah ini.
Langganan:
Postingan (Atom)