Tugas 3 Visual Basic

VB1

Private Sub Command1_Click()
Text1.SetFocus
Text1.Text = “”
Text2.Text = “”
Text3.Text = “”
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text3.SetFocus
End If
End Sub

VB 2

Private Sub Check1_Click()
Label2.FontBold = Check1.Value
End Sub

Private Sub Check2_Click()
Label2.FontItalic = Check2.Value
End Sub

Private Sub Command1_Click()
Label2.Caption = Text1.Text
End Sub

Private Sub Command2_Click()
End
End Sub

Private Sub Option1_Click()
Label2.ForeColor = vbBlue
End Sub

Private Sub Option2_Click()
Label2.ForeColor = vbRed
End Sub

VB3

Private Sub Command1_Click()
If (Check1.Value = 1) And (Check2.Value = 1) And (Check3.Value = 1) Then
Text1.FontBold = True
Text1.FontItalic = True
Text1.FontUnderline = True
ElseIf (Check1.Value = 1) And (Check2.Value = 1) And (Check3.Value = 0) Then
Text1.FontBold = True
Text1.FontItalic = True
Text1.FontUnderline = False
ElseIf (Check1.Value = 1) And (Check2.Value = 0) And (Check3.Value = 1) Then
Text1.FontBold = True
Text1.FontItalic = False
Text1.FontUnderline = True
ElseIf (Check1.Value = 1) And (Check2.Value = 0) And (Check3.Value = 0) Then
Text1.FontBold = True
Text1.FontItalic = False
Text1.FontUnderline = False
ElseIf (Check1.Value = 0) And (Check2.Value = 1) And (Check3.Value = 1) Then
Text1.FontBold = False
Text1.FontItalic = True
Text1.FontUnderline = True
ElseIf (Check1.Value = 0) And (Check2.Value = 1) And (Check3.Value = 0) Then
Text1.FontBold = False
Text1.FontItalic = True
Text1.FontUnderline = False
ElseIf (Check1.Visible = 0) And (Check2.Value = 0) And (Check3.Value = 1) Then
Text1.FontBold = False
Text1.FontItalic = False
Text1.FontUnderline = True
ElseIf (Check1.Value = 0) And (Check2.Value = 0) And (Check3.Value = 0) Then
Text1.FontBold = False
Text1.FontItalic = False
Text1.FontUnderline = False
End If
End Sub

VB 4

Private Sub Command1_Click()
Dim A, B, C As Double
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub

Private Sub Command2_Click()
Text3.Text = Val(Text1.Text) – Val(Text2.Text)
End Sub

Private Sub Command3_Click()
Text3.Text = Val(Text1.Text) * Val(Text2.Text)
End Sub

Private Sub Command4_Click()
Text3.Text = Val(Text1.Text) / Val(Text2.Text)
End Sub

Private Sub Command5_Click()
Text1 = “”
Text2 = “”
Text3 = “”
End Sub

Private Sub Command6_Click()
End
End Sub

VB 5

Private Sub Command1_Click()
Dim hg, jp As Integer
Dim tb As Long
hg = Val(Text3.Text)
jp = Val(Text4.Text)
tb = (hg * jp)
Text5.Text = tb
Text5.SetFocus
End Sub

Private Sub Command2_Click()
Text1.Text = ” ”
Text2.Text = ” ”
Text3.Text = ” ”
Text4.Text = ” ”
Text5.Text = ” ”
End Sub

Private Sub Command3_Click()
Unload Me
End Sub

Private Sub Form_Activate()
Text1.SetFocus
Text1.Text = ” ”
Text2.Text = ” ”
Text3.Text = ” ”
Text4.Text = ” ”
Text5.Text = ” ”
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text3.SetFocus
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text3.SetFocus
End If
End Sub

VB 6

Private Sub cmdhitung_Click()
Dim a, b, c As Double
Text2.Text = Val(Text1.Text) * (0.1)
Text3.Text = Val(Text1.Text) – Val(Text2.Text)
End Sub

Private Sub cmdquit_Click()
Unload Me
End Sub

Private Sub cmdulangi_Click()
Text1.Text = ” ”
Text2.Text = ” ”
Text3.Text = ” ”
End Sub

Private Sub Text1_keypress(keyascii As Integer)
If keyascii = 13 Then
Text2.SetFocus
End If
End Sub

Private Sub Text2_keypress(keyascii As Integer)
If keyascii = 13 Then
Text3.SetFocus
End If
End Sub

Private Sub Text3_keypress(keyascii As Integer)
If keyascii = 13 Then
CMDHITUNG.SetFocus
End If
End Sub

VB 7

Private Sub CMDKELUAR_Click()
Unload Me
End Sub

Private Sub CMDPROSES_Click()
Dim A, B, C, D, E, F As Double
Text4.Text = Val(Text1.Text) + Val(Text2.Text) – Val(Text3.Text)
Text5.Text = Val(Text4.Text) * (0.1)
Text6.Text = Val(Text4.Text) – Val(Text5.Text)
End Sub

Private Sub CMDULANG_Click()
Text1.SetFocus
Text1.Text = ” ”
Text2.Text = ” ”
Text3.Text = ” ”
Text4.Text = ” ”
Text5.Text = ” ”
Text6.Text = ” ”
End Sub

Private Sub Text1_keypress(keyascii As Integer)
If keyascii = 13 Then
Text2.SetFocus
End If
End Sub

Private Sub Text2_keypress(keyascii As Integer)
If keyascii = 13 Then
Text3.SetFocus
End If
End Sub

Private Sub Text3_keypress(keyascii As Integer)
If keyascii = 13 Then
Text4.SetFocus
End If
End Sub

Private Sub Text4_keypress(keyascii As Integer)
If keyascii = 13 Then
Text5.SetFocus
End If
End Sub

Private Sub Text5_keypress(keyascii As Integer)
If keyascii = 13 Then
Text6.SetFocus
End If
End Sub

VB 8

Private Sub Command1_Click()
Dim Quis, Tgs, UTS, UAS, NA As Integer
Dim Hm As String
Quis = Val(Text3.Text)
Tgs = Val(Text4.Text)
UTS = Val(Text5.Text)
UAS = Val(Text6.Text)
NA = (Quis + Tgs + UTS + UAS) / 4
Text7.Text = NA

Select Case Text7.Text
Case Is > 80
Hm = “A”
Case Is > 70
Hm = “B”
Case Is > 60
Hm = “C”
Case Is > 50
Hm = “D”
Case Is < 50
Hm = “E”
End Select
Text8.Text = Hm
End Sub

Private Sub Combo1_CLICK()
Dim nama, jurusan As String
Select Case Combo1.Text
Case “10100454”
nama = “Abdul Soim”
jurusan = “sistem informasi”
Case “10100150”
nama = “Dedi kurinawan”
jurusan = “sistem informasi”
Case “10100196”
nama = “Dwi yulianingsih”
jurusan = “manajemen informatika”
End Select
Text1.Text = nama
Text2.Text = jurusan
Text3.SetFocus

End Sub

Private Sub Command2_Click()
Text1.SetFocus
Text1.Text = ” ”
Text2.Text = ” ”
Text3.Text = ” ”
Text4.Text = ” ”
Text5.Text = ” ”
Text6.Text = ” ”
Text7.Text = ” ”
End Sub
Private Sub Command3_Click()
Unload Me
End Sub

Private Sub Form_Activate()
Text1.SetFocus
Text1.Text = ” ”
Text2.Text = ” ”
Text3.Text = ” ”
Text4.Text = ” ”
Text5.Text = ” ”
Text6.Text = ” ”
Text7.Text = ” ”
End Sub
Private Sub form_load()
Combo1.AddItem “10100454”
Combo1.AddItem “10100150”
Combo1.AddItem “10100196”
End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text4.SetFocus
End If
End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text5.SetFocus
End If
End Sub

Private Sub Text5_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text6.SetFocus
End If
End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text7.SetFocus
End If
End Sub

VB 9

Private Sub Combo1_Click()
Dim gapok, pajak, tunjangan, total As Variant
Select Case Combo1.Text
Case “I”
gapok = 1500000
tunjangan = 150000
Case “II”
gapok = 2000000
tunjangan = 200000
Case “III”
gapok = 2500000
tunjangan = 250000
Case “IV”
gapok = 3000000
tunjangan = 300000
Case Else
gapok = 0
tunjangan = 0
End Select
total = gapok + tunjangan
pajak = total * 0.1
Text3.Text = gapok
Text4.Text = tunjangan
Text5.Text = pajak
Text6.Text = total – pajak
End Sub
Public Sub kosong()
Text1.SetFocus
Text1.Text = “”
Text2.Text = “”
Combo1.Text = “”
Text3.Text = “”
Text4.Text = “”
Text5.Text = “”
Text6.Text = “”
End Sub

Private Sub Command1_Click()
kosong
End Sub

Private Sub Command2_Click()
kosong
End Sub

Private Sub Command3_Click()
Unload Me
End Sub

Private Sub Form_Load()
Combo1.AddItem “I”
Combo1.AddItem “II”
Combo1.AddItem “III”
Combo1.AddItem “IV”
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub

VB 10

Private Sub Command1_Click()
Text1.SetFocus
Text1.Text = “”
Text2.Text = “”
End Sub

Private Sub Command2_Click()
Text3.SetFocus
Text3.Text = “”
Text4.Text = “”
Text5.Text = “”
Text6.Text = “”
End Sub

Private Sub Command3_Click()
Text3.SetFocus
Text3.Text = “”
Text4.Text = “”
Text5.Text = “”
Text6.Text = “”
End Sub

Private Sub Command4_Click()
Unload Me
End Sub

VISUAL BASIC 6.0

VISUAL BASIC

1.1. MENGENAL  MICROSOFT  VISUAL BASIC 6.0

Visual Basic 6.0 merupakan salah satu software pembuat program aplikasi yang sangat handal hingga saat ini. Software ini diambil dari bahasa pemrograman yaitu Visual Basic. Bahasa pemrograman adalah perintah-perintah yang dapat dimengerti oleh computer untuk melakukan tugas-tugas tertentu. Beberapa kemampuan dari Visual Basic adalah dapat membuat aplikasi berbasis Windows yang mandiri (executable), menguji program (debugging), serta membuat obyek-obyek pembantu seperti : ActveX, Help dan lainnya.

Visual Basic 6.0 adalah salah satu bahasa pemrograman untuk membuat program aplikasi dalam lingkungan Windows. Dalam mengembangkan aplikasi VB menggunakan pendekatan GUI (graphical User Interfance) untuk merancang antar muka (interfance). Visual Basic juga merupakan awal dari bahasa-bahasa tingkat tinggi lainnya. Basic dirancang pada tahun 1950-an yang ditunjukkan untuk dapat digunakan oleh programer pemula.

1.2. MEMULAI VISUAL BASIC 6.0

Visual Basic merupakan bahasa pemrograman yang digunakan untuk membuat aplikasi windows yang berbasis grafis Visual Basic 6.0

  • Membuat program-program aplikasi berbasis windows GUI (gravical user intervance) inteksi antara sepenggunaan aplikasi dengan aplikasi antara muka grafik yang disebut sebagai graphical user intervance, yaitu antarmuka grafik memudahkan pemakainya bernafigasi dengan menggunakan user intervance seperti buttom,list,input,failed dan sebagainya.
  • Membuat objek pembantu pemrograman seperti control activex , file, help dan aplikasi internet.
  • Menguji program dan menghasilkan program akhiran EXE yang bersifat executable atau dapat langsung dijalankan.


1.3. TAMPILAN AWAL VISUAL BASIC


Sama seperti program aplikasi berbasis windows, interfance Visual basic terdiri dari menu Bar, Toolbar, Toolbox, dan beberapa panel seperti : Propertis, project, dan From layout. Sesaat setelah menjalankan program Visual Basic maka akan muncul kotak dialog seperti dibawah ini :

LINGKUNGAN KERJA VISUAL BASIC

Tampilan ruang kerja Visual Basic 6.0 (workspace) yang terpadu untuk membuat program aplikasi. Ruang kerja terpadu ini disebut dengan IDE (integrated Development Enviroment), dengan tampilan seperti dibawah ini : Layar Visual Basic adalah suatu lingkungan besar mempunyai beberapa bagian kecil yang memiliki sifat :

1.      Floating : Dapat digeser-geser keposisi mana saja dengan menggunakan mouse.

2.      Sizeable : Dapat diubah-ubah ukurannya,seperti halnya merubah ukuran pada jendela      Windows.

3.      Dockable: Dapat menempel pada bagian lain yang berdekatan.Dapat dipindah-pindahkan, digeser, diperbesar atau diperkecil ukuran setiap komponen layer Visual Basic sama dengan memanipulasi jendela Windows.

Gambar. Lingkungan visual basic

1.5. KOMPONEN-KOMPONEN VISUAL BASIC

1. Title bar

Titlebar merupakan batang judul dari program Visual Basic 6.0 yang terletak pada bagian paling atas dari jendela program, selain itu berfungsi untuk menampilkan judul atau nama jendela.

Fungsi titlebar

  • Memindahkan jendela dengan menggunakan proses drag and drop pada posisi titlebar tersebut
  • Mengatur ukuran jendela dari ukuran maximize ke ukuran restore atau sebaliknya dengan melakukan klik pada posisi titlebar tersebut.

Gambar. Titlebar

2. Menu bar

Adalah tempat dimana perintah (menu) ditempatkan secara hirarki, yaitu Menu > submenu > sub-sub menu. Menu juga dapat diakses dengan cara klik kanan diarea kosong pada form, atau dapat pula dengan menekan tombol Alt + huruft yang digaris bawahi (hotkey).

Gambar. Menubar

3. Tool bar

Toolbar adalah tempat sekumpulan icon yang merupakan ciri dari aplikasi barbasis windows. Pada tampilan utama Visual Basic, yakni menampilkan toolbar standar.

Gambar. Toolbar

4. ToolBox

toolbox letaknya disebelah kiri tampilan yang terdiri dari beberapa icon untuk membuat kontrol dalam form. Tetapi tidak semua icon ditampilkan dalam ToolBox, untuk menampilkan icon yang lain dapat dilakukan dengan menekan klik kanan pada toolBox atau pilih menu Project, Component.


Gambar. Toolbox

5. Project Explorer

Setiap aplikasi dalam Visual Basic disebut dengan Project dan setiap projrct dapat terdiri dari beberapa file. Project explorer berfungsi untuk menampilkan daftar form dan modul yang terdapat pada proyek aplikasi yang sedang dikerjakan.

Project juga berisi dengan file-file berbeda yaitu   :

  • Project, sebagai file induk
  • Form file
  • Class module, bersifat oprasional
  • Standar module
  • active control file
  • Single resource file

Gambar. Project exploler

6. Form designer

Merupakan jendela untuk merancang aplikasi yang sedang dibuat. Form Designer ibarat “kanvas” untuk “melukis” user interface. Form dapat disamakan dengan area halaman kerja, yang nantinya dalam aplikasdi sering disebut sebagai Windows.

Gambar. Form designer

7. Properties Windows

Jendela properties berisi informasi mengenai objek atau kontrol terpilih yang berada dalam aplikasi Visual Basic. Properties suatu objek/kontrol meliputi nama objek (name), judul (caption), warna, posisi dan lainnya.

Gambar. Properties window

8. Form layout windows

Panel ini dapat digunakan untuk mengatur posisi form pada saat aplikasi tersebut dijalankan/ditampilkan. Dan dapat digunakan untuk mengontrol posisi form dalam aplikasi dengan menggunakan sistem grafik dalam sebuah layar. Dengan fasilitas ini kita dapat melihat dan mendengar posisi form yang baru kita disaign.

Gambar. Form layout window

9. Code Windows

Jendela Code adalah suatu tempat dimana kita dapat menempatkan atau memberikan kode/ perintah pada objek terpilih.

Gambar. Code window

10. Method

Kumpulan perintah yang memiliki kegunaan yang hampir sama dengan satu fungsi atau prosedur tetapi perintah-perintah sudah disediakan dalam suatu objek.

Method umumnya digunakaan untuk menjalankan perintah khusus pada suatu objek tertentu.

Gambar. Method

11. Event

Event adalah suatu blok kode program yang dieksekusi apabila ada objek yang manipulasi pada program, sebagai contoh perintah pertama pada program. Event procedur command cuck akan dijalankan. Event procedure biasanya memeriksa dan menset properti serta menggunakan pernyataan program lain untuk melakukan pekerjaan program.

 

Gambar. Event

12. Module

Fungsinya hampir sama dengan form,tetapi module tidak berisi objek atau bentuk standar,dan module berisikan kode program atau prosedure yang dapat digunakan dengan program aplikasi.

Module dapat disejajarkan dengan form, tetapi tidak mengandung objek dan bentuk standar. Module dapat berisi beberapa kode program atau prosedur yang dapat digunakan dalam program aplikasi. Untuk membuat modul sendiri, kita dapat memasukkan ke dalam program aplikasi dengan menu Project lalu Add Module.

Rancang situs seperti ini dengan WordPress.com
Mulai