MEMBUAT DATA BASE PADA VISUAL BASIC – TUGAS VISUAL BASIC

Data base yaitu tmpat penyimpanan data pada visual basic. Teman -teman pasti sudah membuat banyak program, akan tetapi data yang di inputkan tidak tersimpan, seperti biasa, ane dpt tugas lgi dari dosen, yaitu suruh bikin data base… nah untuk itu mari kita buat bersama – sama data basenya:

–          Buka aplikasi visual basic

–          Buatlah form seperti berikut

Image

–          Untuk pembuatan data base nya, klik Add-ins, kemudian pilih visual data manager…

–          Muncul kotak dialog Visdata, kemudian klik file-new-microsoft acces-version 7.0 MDB

–          Setelah itu mucul kotak dialog save,, ktik nama dokumen nya,, contohnya “dbryan” lalu klik save

–          Kemudian pada properties, klik kanan dan pilih new table

–          Tulis nama table pada table name,, lalu klik add field, kemudian pada kolom name ketik field sesuai soal, seperti “nama”, “alamat”, dll…. Selesai klik close lalu klik build the table..

–          Muncullah nama table yang telah kita buat dibawah properties,, klik 2X, maka akan muncul kotak dialog baru.

–          Klik add,, lalu masukkan nama anda, kemudian klik update,, lalu yes,, begitu selanjutnya sampai data base yang telah ditentukan sebelumnya. Setelah selesai lalu close.

–          Kembali lagi ke form yang telah kita buat sebelumnya, klik project-component (CTRL + T) kemudian beri tanda ceklist pada Microsoft data bound grid control 5.0 (SP3) lalu ok, dan pada properties akan muncul DbGrid

–          Drag n drop Dbgrid ke form,, sesuaikan saja seperti gambar,,  data juga demikian.

–          Klik ada/aktifkan data, kemudian pada properties data di kolom databaseName input link penyimpanan source kode yang telah disimpan sebelumnya, seperti “E:\Dbryan.mdb”, kemudian pada recordsource pilih nama table kalin, contohnya “tbryan”.

–          Klik Dbgrid yang telah kalian buat, lalu pada properties di kolom data source, pilih Data1, karena memang datanya ada 1.

–          Klik pada kolom text, pada properties pilih datasource=data1, dan dan datafield=Nama, (tergantung pada banyak nya field yang anda buat)

–          Dobel klik pada command1, lalu masukkan listing program berikut:

Private Sub Command1_Click()

Dim s As String

Text5.Text = “20” & Left(Text2.Text, 2)

s = Mid(Text2.Text, 3, 1)

If s = “1” Then

s = “Sistem Informasi”

ElseIf s = “2” Then

s = “Manajemen Informasi”

ElseIf s = “3” Then

s = “Tekhnik Informasi”

End If

Text3.Text = s

b = Mid(Text2.Text, 4, 2)

If b = “00” Then

b = “strata 1”

ElseIf b = “01” Then

b = “Diploma 3”

ElseIf b = “02” Then

b = “Diploma 2”

End If

Text4.Text = b

Text6.Text = Right(Text2.Text, 3)

End Sub

–          Kemudian pada command2 masukkan listing program berikut:

Private Sub Command2_Click()

Data1.Recordset.AddNew

Text1.SetFocus

End Sub

–          Pada command 3 masukkan listing program berikut:

Private Sub Command3_Click()

Data1.Recordset.Update

Data1.Recordset.AddNew

Text1.SetFocus

Text1 = “”

Text2 = “”

Text3 = “”

Text4 = “”

Text5 = “”

Text6 = “”

End Sub

–          Pada command4 masukkan listing program berikut:

Private Sub Command3_Click()

Data1.Recordset.Update

Data1.Recordset.AddNew

Text1.SetFocus

Text1 = “”

Text2 = “”

Text3 = “”

Text4 = “”

Text5 = “”

Text6 = “”

End Sub

–          Pada command 5, masukkan lisitng berikut:

Private Sub Command5_Click()

Unload Me

End Sub

–          Coba anda jalankan program, dan hasilnya sebagai berikut:

Image

Advertisements

TUGAS QUIS 4

Ane hari ini dikasih tugas ama dosen tuk nyelesain soal2 quis minggu kmren,, oke ayo kita kerjain….

  • Buka aplikasi visual basic
  • Buat forem sperti berikut

Image

  • Pada command proses, masukkan kode seperti berikut

Private Sub Command1_Click()

Dim JB, PN, PB As String

Dim H As Currency

Text4.Text = “20” & Right(Combo1, 2)

A = Mid(Combo1, 3, 3)

If A = “SIM” Then

JB = “Sistem Informasi Manajemen”

PN = “Yati Nur Oktavia”

H = “75900”

ElseIf A = “EDP” Then

JB = “Elektronik Data Processing”

PN = “Imam Tarmizi”

H = “62000”

ElseIf A = “MNJ” Then

JB = “Manajemen”

PN = “Valentina Mariana Adiwianti”

H = “42000”

ElseIf A = “CDR” Then

JB = “Corel Draw”

PN = “Rian Suhandi”

H = “53000”

ElseIf A = “RPL” Then

JB = “Rekayasa Perangkat Lunak”

PN = “Sinta Umpu Singa”

H = “83000”

End If

Text2.Text = JB

Text3.Text = PN

Text6.Text = H

B = Left(Combo1, 1)

If B = “A” Then

Text5.Text = “Andi offset Yogyakarta”

ElseIf B = “I” Then

Text5.Text = “Indah Surabaya”

ElseIf B = “S” Then

Text5.Text = “Salemba Empat”

ElseIf B = “E” Then

Text5.Text = “Elek Media Komputindo”

ElseIf B = “M” Then

Text5.Text = “Maxicom”

End If

End Sub

 

  • Selesai. Untuk command2 yg lain,, agan2 pasti dah ngerti donk…
  • Ni hasilnya….

 

 

 

 

 

 Image

TUGAS QUIS 3

Ane hari ini dikasih tugas ama dosen tuk nyelesain soal2 quis minggu kmren,, oke ayo kita kerjain….

  • Buka aplikasi visual basic
  • Buat forem sperti berikut

Image

  • Pada command proses, masukkan kode seperti berikut

Private Sub Command1_Click()

Dim JBT, BG As String

Dim GP, TJ, TG As Currency

Text4.Text = Left(Text11.Text, 4)

G = Mid(Text11.Text, 5, 1)

If G = “A” Then

G = “A”

JBT = “Manajer”

GP = “4000000”

TJ = “1025000”

ElseIf G = “B” Then

G = “B”

JBT = “Ka. Seksi”

GP = “3500000”

TJ = “975000”

ElseIf G = “C” Then

G = “C”

JBT = “Staff”

GP = “3000000”

TJ = “925000”

End If

Text10.Text = G

Text5.Text = JBT

Text7.Text = GP

Text8.Text = TJ

KS = Mid(Text11.Text, 7, 1)

If KS = “S” Then

KS = “S”

Stat = “Single”

ElseIf KS = “M” Then

KS = “M”

Stat = “Menikah”

ElseIf KS = “J” Then

KS = “J”

Stat = “Janda”

ElseIf KS = “D” Then

KS = “D”

Stat = “Duda”

End If

Text2.Text = KS

Text3.Text = Stat

B = Right(Text11.Text, 3)

If B = “KEU” Then

Text6.Text = “Accounting”

ElseIf B = “ADM” Then

Text6.Text = “Administrasi”

ElseIf B = “SDM” Then

Text6.Text = “General Affair”

ElseIf B = “EDP” Then

Text6.Text = “IT Unit”

ElseIf B = “SPM” Then

Text6.Text = “Security”

End If

Text9.Text = Val(Text7.Text) + Val(Text8.Text)

End Sub

 

  • Selesai. Untuk command2 yg lain,, agan2 pasti dah ngerti donk…
  • Ni hasilnya….

 

 

 

 Image

TUGAS QUIS 2

ane hari ini dikasih tugas ama dosen tuk nyelesain soal2 quis minggu kmren,, oke ayo kita kerjain….

  • Buka aplikasi visual basic
  • Buat forem sperti berikut

Image

  • Pada command proses, masukkan kode seperti berikut

Private Sub Command1_Click()

Dim JB, PN, PB As String

Dim H As Currency

Text4.Text = “20” & Mid(Text1.Text, 5, 2)

A = Left(Text1.Text, 3)

If A = “SIM” Then

JB = “Sistem Informasi Manajemen”

PN = “Fadiya Ulfa”

H = “75900”

ElseIf A = “EDP” Then

JB = “Elektronik Data Processing”

PN = “Nurul Agustina”

H = “62000”

ElseIf A = “MNJ” Then

JB = “Manajemen”

PN = “Rian Hidayat”

H = “42000”

ElseIf A = “CDR” Then

JB = “Corel Draw”

PN = “Siti Nur Khotimah”

H = “53000”

ElseIf A = “RPL” Then

JB = “Rekayasa Perangkat Lunak”

PN = “Winda Erlianti”

H = “83000”

End If

Text2.Text = JB

Text3.Text = PN

Text6.Text = H

B = Right(Text1.Text, 1)

If B = “A” Then

Text5.Text = “Andi offset Yogyakarta”

ElseIf B = “I” Then

Text5.Text = “Indah Surabaya”

ElseIf B = “S” Then

Text5.Text = “Salemba Empat”

ElseIf B = “E” Then

Text5.Text = “Elek Media Komputindo”

ElseIf B = “M” Then

Text5.Text = “Maxicom”

End If

End Sub

 

  • Selesai. Untuk command2 yg lain,, agan2 pasti dah ngerti donk…
  • Ni hasilnya….

 

 Image

TUGAS QUIS 1

Ane hari ini dikasih tugas ama dosen tuk nyelesain soal2 quis minggu kmren,, oke ayo kita kerjain….

  • Buka aplikasi visual basic
  • Buat forem sperti berikut

Image

  • Pada command proses, masukkan kode seperti berikut

Private Sub Command1_Click()

Dim JB, PN, PB As String

Dim H As Currency

Text4.Text = “20” & Right(Text1.Text, 2)

A = Mid(Text1.Text, 3, 3)

If A = “SIM” Then

JB = “Sistem Informasi Manajemen”

PN = “Andra setiawan”

H = “75900”

ElseIf A = “EDP” Then

JB = “Elektronik Data Processing”

PN = “Desi Istiqomah”

H = “62000”

ElseIf A = “MNJ” Then

JB = “Manajemen”

PN = “Sandi fitrajaya”

H = “42000”

ElseIf A = “CDR” Then

JB = “Corel Draw”

PN = “Ernita Sari”

H = “53000”

ElseIf A = “RPL” Then

JB = “Rekayasa Perangkat Lunak”

PN = “Winda Erlianti”

H = “83000”

End If

Text2.Text = JB

Text3.Text = PN

Text6.Text = H

B = Left(Text1.Text, 1)

If B = “A” Then

Text5.Text = “Andi offset Yogyakarta”

ElseIf B = “I” Then

Text5.Text = “Indah Surabaya”

ElseIf B = “S” Then

Text5.Text = “Salemba Empat”

ElseIf B = “E” Then

Text5.Text = “Elek Media Komputindo”

ElseIf B = “M” Then

Text5.Text = “Maxicom”

End If

End Sub

  • Selesai. Untuk command2 yg lain,, agan2 pasti dah ngerti donk…
  • Ni hasilnya….

Image

Tugas VB 3

1.

desi1

Private Sub Cbonpm_DblClick()

Private Sub form_load()

Cbonpm.AddItem “12201050”

Cbonpm.AddItem “12100305”

Cbonpm.AddItem “12100117”

Cbonpm.AddItem “12201009”

Cbonpm.AddItem “12201268”

End Sub

 

Private Sub Cbonpm_Click()

Dim nama, jurusan, AsString

 

Select Case Cbonpm.Text

Case “12201050”

nama = “Desi Anita”

jurusan = “Manajemen Informatika”

Case “12100305”

nama = “Yustika”

jurusan = “Sistem Informasi”

Case “12100117”

nama = “Helen”

jurusan = “Sisitem Informasi”

Case “12201009”

nama = “Arif Hidayat”

jurusan = “Manajemen Informatika”

Case “12201268”

nama = “Hernika”

jurusan = “Manajemen Informatika”

End Select

Txtnm.Text = nama

Txtjur.Text = jurusan

Txtqz.SetFocus

End Sub

 

 

Private Sub Txtqz_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Txttg.SetFocus

End If

End Sub

 

Private Sub Txttg_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Txtuts.SetFocus

End If

End Sub

 

 

 

Private Sub Txtuts_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Txtuas.SetFocus

End If

End Sub

 

Private Sub Cmdproses_Click()

Dim NilaiAkhir As Integer

Dim HurufMutu As String

quiz = Val(Txtqz.Text)

tugas = Val(Txttg.Text)

uts = Val(Txtuts.Text)

uas = Val(Txtuas.Text)

NilaiAkhir = (quiz + tugas + uts + uas) / 4

Txtna.Text = NilaiAkhir

 

Select Case Txtna.Text

Case Is > 80

HurufMutu = “A”

Case Is > 70

HurufMutu = “B”

Case Is > 60

HurufMutu = “C”

Case Is > 50

HurufMutu = “D”

Case Is <50

HurufMutu = “E”

End Select

Txthm.Text = HurufMutu

End Sub

 

Private Sub Cmdbtl_Click()

Cbonpm.SetFocus

Cbonpm = “”

Txtnm = “”

Txtjur = “”

Txtqz = “”

Txttg = “”

Txtuts = “”

Txtuas = “”

Txtna = “”

Txthm = “”

End Sub

 

Private Sub Cmdkelw_Click()

End

End Sub

2.

desi2

Private Sub Optmrh_Click()

Lblnama.ForeColor = vbRed

End Sub

 

Private Sub Opthij_Click()

Lblnama.ForeColor = vbGreen

End Sub

 

Private Sub Chkmrg_Click()

Lblnama.FontItalic = Chkmrng.Value

End Sub

 

Private Sub Chktbl_Click()

Lblnama.FontBold = Chktbl.Value

End Sub

 

Private Sub Cmdok_Click()

Lblnama.Caption = Txtnam.Text

End Sub

 

Private Sub Cmdkelw_Click()

End

End Sub

3.

DESI3

Private Sub Txtnidn_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Txtnmpg.SetFocus

End If

End Sub

 

Private Sub Cbogol_DblClick()

Private Sub form_load()

Cbogol.AddItem “I”

Cbogol.AddItem “II”

Cbogol.AddItem “III”

Cbogol.AddItem “IV”

End Sub

 

Private Sub Cbogol_Click()

Dim Gajipokok, Pajak, Tunjangan, Total As Variant

Select Case Cbogol.Text

Case “I”

Gajipokok = 2500000

Tunjangan = 300000

Case “II”

Gajipokok = 3000000

Tunjangan = 500000

 

Case “III”

Gajipokok = 3500000

Tunjangan = 700000

Case “IV”

Gajipokok = 4000000

Tunjangan = 900000

Case Else

Gajipokok = 0

Tunjangan = 0

End Select

Total = Gajipokok + Tunjangan

Pajak = Total * 0.1

Txtgjpk.Text = Gajipokok

Txttnjg.Text = Tunjangan

Txtpjk.Text = Pajak

Txtttl.Text = Total – Pajak

 

 

Private Sub Cmdlgi_Click()

Txtnidn = “”

Txtnmpg = “”

Cbogol = “”

Txtgjpk = “”

Txttnjg = “”

Txtpjk = “”

Txtttl = “”

End Sub

 

Private Sub Cmdbtl_Click()

Txtnidn = “”

Txtnmpg = “”

Cbogol = “”

Txtgjpk = “”

Txttnjg = “”

Txtpjk = “”

Txtttl = “”

End Sub

 

Private Sub Cmdklwr_Click()

End

End Sub

4.

desi4

Private Sub Txtnm_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Txtnpm.SetFocus

End If

End Sub

 

 

Private Sub Cmdpros_Click()

Dim S As String

Txtthn.Text = “20” & Left(Txtnpm.Text, 2)

S = Mid(Txtnpm.Text, 3, 1)

If S = “1” Then

Txtjurs.Text = “Sisitem Informasi”

ElseIf S = “2” Then

Txtjurs.Text = “Manajemen Informatika”

ElseIf S = “3” Then

Txtjurs.Text = “Komputer Akuntansi Manajemen”

ElseIf S = “4” Then

Txtjurs.Text = “Tehnik Informatika”

End If

S = Mid(Txtnpm.Text, 4, 2)

If S = “00” Then

Txtps.Text = “Strata Satu”

ElseIf S = “01” Then

Txtprs.Text = “Diploma Tiga”

ElseIf S = “02” Then

Txtprs.Text = “Diploma Dua”

ElseIf S = “03” Then

Txtprs.Text = “Diploma Satu”

End If

S = Right(Txtnpm.Text, 3)

Txtnourt.Text = Right(Txtnpm.Text, 3)

End Sub

 

Private Sub Cmdlgi_Click()

Txtnm.SetFocus

Txtnm = “”

Txtnpm = “”

Txtjrsn = “”

Txtprs = “”

Txtthn = “”

Txtnourt = “”

End Sub

 

Private Sub Cmdbtl_Click()

Txtnama.SetFocus

Txtnm = “”

Txtnpm = “”

Txtjrsn = “”

Txtprs = “”

Txtthn = “”

Txtnourt = “”

End Sub

 

Private Sub Cmdklwr_Click()

End

End Sub

TUGAS VISUAL BASIC PERTEMUAN 2

1.

desi1

Private Sub txta1_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txta2.SetFocus

End If

End Sub

Private Sub txta2_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Txta3.SetFocus

End If

End Sub

Private Sub Txta3_KeyPress(KeyAscii As Integer)

Txta3.Text = Val(txta1.Text) * Val(txta2.Text)

End Sub

Private Sub Cmdhit_Click()

Txta3.Text = Val(txta1.Text) * Val(txta2.Text)

End Sub

Private Sub Cmdbrsh_Click()

txta1 = “”

txta2 = “”

Txta3 = “”

End Sub

Private Sub Cmdkel_Click()

End

End Sub

2.

desi4

Private Sub Cmdprs_Click()

Txtdsk.Text = Val(Txtnil1.Text) * 0.1

Txtnil2.Text = Val(Txtnil1.Text) – Val(Txtdsk.Text)

End Sub

Private Sub Cmdlagi_Click()

Txtnil1 = “”

Txtdsk = “”

Txtnil2 = “”

End Sub

Private Sub Cmdout_Click()

End

End Sub

3.

desi5

Private Sub Txtbl1_Change()

If KeyAscii = 13 Then

Txtbl2.SetFocus

End If

End Sub

Private Sub Cmdkl_Click()

Txtjml.Text = Val(Txtbl1.Text) * Val(Txtbl2)

End Sub

Private Sub Cmdbg_Click()

Txtjml.Text = Val(Txtbl1.Text) / Val(Txtbl2)

End Sub

Private Sub Cmdtb_Click()

Txtjml.Text = Val(Txtbl1.Text) + Val(Txtbl2.Text)

End Sub

Private Sub Cmdkr_Click()

Txtjml.Text = Val(Txtbl1.Text) – Val(Txtbl2.Text)

End Sub

Private Sub Cmdlagi_Click()

Txtbl1 = “”

Txtbl2 = “”

Txtjml = “”

End Sub

Private Sub Cmdklr_Click()

End

End Sub

4.

desi2

Private Sub optbl_Click()

Lblmsvb.ForeColor = vbBlue

End Sub

Private Sub optgr_Click()

Lblmsvb.ForeColor = vbGreen

End Sub

Private Sub optrd_Click()

Lblmsvb.ForeColor = vbRed

End Sub

Private Sub Optyl_Click()

Lblmsvb.ForeColor = vbYellow

End Sub

Private Sub Chkitalic_Click()

If Chkitalic.Value = 1 Then

Lblmsvb.FontItalic = True

Else

Lblmsvb.FontItalic = False

End If

End Sub

Private Sub Chkbold_Click()

If Chkbold.Value = 1 Then

Lblmsvb.FontBold = True

Else

Lblmsvb.FontBold = False

End If

End Sub

Private Sub Chkunderline_Click()

If Chkunderline.Value = 1 Then

Lblmsvb.FontUnderline = True

Else

Lblmsvb.FontUnderline = False

End If

End Sub

Private Sub Chkstrikethru_Click()

If Chkstrikethru.Value = 1 Then

Lblmsvb.FontStrikethru = True

Else

Lblmsvb.FontStrikethru = False

End If

End Sub

Private Sub Cmdkelwr_Click()

End

End Sub

5.

desi3

Private Sub Txtgp_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Txttj.SetFocus

End If

End Sub

Private Sub Txttj_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Txtpt.SetFocus

End If

End Sub

Private Sub Cmdpros_Click()

Txtgk.Text = Val(Txtgp.Text) + Val(Txttj.Text) – Val(Txtpt.Text)

Txtpj.Text = Val(Txtgk.Text) * 0.1

Txtgb.Text = Val(Txtgk.Text) – Val(Txtpj.Text)

End Sub

Private Sub Cmdlg_Click()

Txtgp = “”

Txttj = “”

Txtpt = “”

Txtgk = “”

Txtpj = “”

Txtgb = “”

End Sub

Private Sub Cmdkel_Click()

End

End Sub