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

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

Visual Basic Pertemuan 3

1.

rina1

Private Sub Cbonpm_Click()

Dim nama, jurusan, AsString

Select Case Cbonpm.Text

Case “12201044”

nama = “Amrina Sari”

jurusan = “Manajemen Informatika”

Case “12100311”

nama = “EkoMualip”

jurusan = “Sistem Informasi”

Case “12100017”

nama = “Desi Anita”

jurusan = “Tehnik Informatika”

Case “12100512”

nama = “Rudiyansah”

jurusan = “Manajemen Informatika”

Case “12100013”

nama = “RuliSetiawan”

jurusan = “Sisitem Informasi”

End Select

Txtnam.Text = nama

Txtjur.Text = jurusan.

Private Sub Cbogol_DblClick()

Private Sub form_load()

Cbonpm.AddItem “12201044”

Cbonpm.AddItem “12100311”

Cbonpm.AddItem “12100017”

Cbonpm.AddItem “12100512”

Cbonpm.AddItem “12100013”

End Sub

Private Sub Txtqz_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Txttug.SetFocus

End If

End Sub

Private Sub Txttug_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 NilaiAkhirAs Integer

Dim HurufMutuAs String

quiz = Val(Txtqz.Text)

tugas = Val(Txttug.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 = “”

Txtnam = “”

Txtjur = “”

Txtqz = “”

Txttug = “”

Txtuts = “”

Txtuas = “”

Txtna = “”

Txthm = “”

End Sub

Private Sub Cmdkelwr_Click()

End

End Sub

2.

rina2

Private Sub Opthij_Click()

Lblnam.ForeColor = vbGreen

End Sub

Private Sub Optmrh_Click()

Lblnam.ForeColor = vbRed

End Sub

Private Sub Chktbl_Click()

Lblnam.FontBold = Chktbl.Value

End Sub

Private Sub Chkmrng_Click()

Lblnam.FontItalic = Chkmrng.Value

End Sub

Private Sub Cmdok_Click()

Lblnam.Caption = Txtnm.Text

End Sub

Private Sub Cmdkelwr_Click()

End

End Sub

3.

Amrina3

Private Sub Txtnidn_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Txtnpg.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, GajibersihAs Variant

Select Case Cbogol.Text

Case “I”

Gajipokok = 2000000

Tunjangan = 200000

Case “II”

Gajipokok = 3000000

Tunjangan = 300000

Case “III”

Gajipokok = 4000000

Tunjangan = 400000

Case “IV”

Gajipokok = 5000000

Tunjangan = 500000

Case Else

Gajipokok = 0

Tunjangan = 0

End Select

Gajibersih = Gajipokok + Tunjangan

Pajak = Gajibersih * 0.1

Txtgp.Text = Gajipokok

Txttj.Text = Tunjangan

Txtpj.Text = Pajak

Txtgtr = Gajibersih – Pajak

Private Sub Cmdlg_Click()

Txtnidn = “”

Txtnpg = “”

Cbogol = “”

Txtgp = “”

Txttj = “”

Txtpj = “”

Txtgtr = “”

End Sub

Private Sub Cmdbtl_Click()

Txtnidn = “”

Txtnpg = “”

Cbogol = “”

Txtgp = “”

Txttj = “”

Txtpj = “”

Txtgtr = “”

End Sub

Private Sub Cmdkelwr_Click()

End

End Sub

4.

rina4

Private Sub Txtnm_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Txtnpm.SetFocus

End If

End Sub

Private Sub Cmdprs_Click()

Dim SAs String

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

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

If S = “1” Then

Txtjur.Text = “Sisitem Informasi”

ElseIf S = “2” Then

Txtjur.Text = “Manajemen Informatika”

ElseIf S = “3” Then

Txtjur.Text = “Tehnik Informatika”

ElseIf S = “4” Then

Txtjur.Text = “Komputer Akuntansi”

End If

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

If S = “00” Then

Txtprst.Text = “Strata Satu”

ElseIf S = “01” Then

Txtprst.Text = “Diploma Dua”

ElseIf S = “02” Then

Txtprst.Text = “Diploma Tiga”

ElseIf S = “03” Then

Txtprst.Text = “Diploma Satu”

End If

S = Right(Txtnpm.Text, 3)

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

End Sub

Private Sub Cmdlgi_Click()

Txtnm.SetFocus

Txtnm = “”

Txtnpm = “”

Txtjur = “”

Txtprst = “”

Txttm = “”

Txtno = “”

End Sub

Private Sub Cmdbtl_Click()

Txtnm.SetFocus

Txtnm = “”

Txtnpm = “”

Txtjur = “”

Txtprst = “”

Txttm = “”

Txtno = “”

End Sub

Private Sub Cmdkelwr_Click()

End

End Sub

Tugas VB Pertemuan 2

1.

 

Am1

Private Sub txtak1_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

txtak2.SetFocus

End If

End Sub

 

Private Sub txtak2_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Txtak3.SetFocus

End If

End Sub

 

Private Sub Txtak3_KeyPress(KeyAscii As Integer)

Txtak3.Text = Val(txtak1.Text) * Val(txtak2.Text)

End Sub

 

Private Sub Cmdhit_Click()

Txtak3.Text = Val(txtak1.Text) * Val(txtak2.Text)

End Sub

 

Private Sub Cmdbrsh_Click()

txtak1 = “”

txtak2 = “”

Txtak3 = “”

End Sub

 

Private Sub Cmdkel_Click()

End

End Sub

2.

Am3

Private Sub Txtgp_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Txttnj.SetFocus

End If

End Sub

 

Private Sub Txttnj_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

Txtpt.SetFocus

End If

End Sub

 

 

Private Sub Cmdpros_Click()

Txtgkt.Text = Val(Txtgp.Text) + Val(Txttnj.Text) – Val(Txtpt.Text)

Txtpjk.Text = Val(Txtgkt.Text) * 0.1

Txtgbr.Text = Val(Txtgkt.Text) – Val(Txtpjk.Text)

End Sub

 

Private Sub Cmdlgi_Click()

Txtgp = “”

Txttnj = “”

Txtpt = “”

Txtgkt = “”

Txtpjk = “”

Txtgbr = “”

End Sub

 

Private Sub Cmdkel_Click()

End

End Sub

3.

Am2

Private Sub optblu_Click()

Lbljudul.ForeColor = vbBlue

End Sub

 

Private Sub optgrn_Click()

Lbljudul.ForeColor = vbGreen

End Sub

 

Private Sub optred_Click()

Lbljudul.ForeColor = vbRed

End Sub

 

Private Sub Optyelow_Click()

Lbljudul.ForeColor = vbYellow

End Sub

 

 

Private Sub Chkbold_Click()

If Chkbold.Value = 1 Then

Lbljudul.FontBold = True

Else

Lbljudul.FontBold = False

End If

End Sub

 

Private Sub Chkitalic_Click()

If Chkitalic.Value = 1 Then

Lbljudul.FontItalic = True

Else

Lbljudul.FontItalic = False

End If

End Sub

 

 

Private Sub Chkunder_Click()

If Chkunder.Value = 1 Then

Lbljudul.FontUnderline = True

Else

Lbljudul.FontUnderline = False

End If

End Sub

 

Private Sub Chkstrik_Click()

If Chkstrik.Value = 1 Then

Lbljudul.FontStrikethru = True

Else

Lbljudul.FontStrikethru = False

End If

End Sub

 

Private Sub Cmdklwr_Click()

End

End Sub

4.

Am4

Private Sub Cmdhit_Click()

Txtdskn.Text = Val(Txtn1.Text) * 0.1

Txtn2.Text = Val(Txtn1.Text) – Val(Txtdskn.Text)

End Sub

 

Private Sub Cmdlagi_Click()

Txtn1 = “”

Txtdskn = “”

Txtn2 = “”

End Sub

 

Private Sub Cmdout_Click()

End

End Sub

5.

Am5

Private Sub Txtnl1_Change()

If KeyAscii = 13 Then

Txtnl2.SetFocus

End If

End Sub

 

Private Sub Cmdkil_Click()

Txtjmlh.Text = Val(Txtnl1.Text) * Val(Txtnl2)

End Sub

 

Private Sub Cmdbgi_Click()

Txtjmlh.Text = Val(Txtnl1.Text) / Val(Txtnl2)

End Sub

 

Private Sub Cmdtbh_Click()

Txtjmlh.Text = Val(Txtnl1.Text) + Val(Txtnl2.Text)

End Sub

 

Private Sub Cmdkrg_Click()

Txtjmlh.Text = Val(Txtnl1.Text) – Val(Txtnl2.Text)

End Sub

 

Private Sub Cmdlagi_Click()

Txtnl1 = “”

Txtnl2 = “”

Txtjmlh = “”

End Sub

 

Private Sub Cmdklwr_Click()

End

End Sub