Learning Visual Basic


Visual Basic adalah alat yang berguna untuk mengaplikasikan sebuah pemikiran akan idealism program yang terlintas di benak seorang programmer dalam kerangka dependensi terhadap operating system non open source yang dalam hal ini windows. Programmer bukanlah tertuju hanya kepada seseorang yang begitu tekun dan mendalami sebuah konsep program, akan tetapi programmer secara global dapat diartikan sebagai sosok yang memikirkan rekondisi program juga memikirkan langkah-langkah awal dalam pemrograman.

Sekarang, kita bikin Program yang dinamakan Kenalan_Yukz.

  • Jalankan VB. Bikin form, command button. Ubah properti Caption jadi Kenalan Yukz.
  • Klik Ganda Command1,Ketikkan.

Dim myvar

myvar = InputBox(“Masukkan nama Anda !! “)

MsgBox “Senang berkenalan dengan ” & myvar

  • Klik Start/tekan F5, Lihat

Sekarang kita bikin Program Apa Kabar Dunia

  • Bikin textbox, command botton
  • Ganti text yg ada di command button dengan cara mengklik buttonnya. Masuk ke properties dan ganti caption command1 dengan Okay Dong, lalu tekan enter.
  • Sekarang klik textbox yg ada di form, tekan ß (backspace).
  • Klik ganda form, lalu kita tulis kode begini:

Private Sub Form_Load()

Text1.text = “Apa kabar dunia?”

End Sub

  • Tutup jendela code. Klik ganda tombol Okay Dong. Ketik:

Unload Me

  • File > save project as > (kita ganti Project1.vbp dengan Projectbiasa.vbp) > save
  • Coba (F5).

Buat satuan hari dan jam

  • Bikin satu kontrol label, klik kanan-copy,klik-form-paste sebanyak 4 kali. Akan ada tulisan

             “You already have control named ‘label1’. Do you wish to continue?”

  • Klik ok
  • Klik font di properties di tiap label, ubah aja semau anda. Lalu tekan OK
  • Ubah caption di properties form1 dengan Kalender_Keren. Tambahkan control timer yg bentuknya seperti jam ke dalam form. Ubah property interval dengan nilai 1000
  • Klik ganda control timer. Lalu ketikkan:

Dim today As Variant

today = Now

Label1.Caption = Format(today, “ddddd”)

Label2.Caption = Format(today, “mmmm”)

Label3.Caption = Format(today, “yyyy”)

Label4.Caption = Format(today, “d”)

Label5.Caption = Format(today, “h:mm:ss ampm”)

  • Save

Program Banyak Form

  • Masuk vb, bikin 3 command button.
    1. Command1 = Loading Semua Form
    2. Command2 = Unloading semua form
    3. Command3 = Udah pengen muntah
  • Klik di form1, ketikkan:

Private Sub Command1_Click()

Command2.Enabled = True

Form2.Caption = “Form Ukuran”

Form3.Caption = “Form Gambar”

Form2.Show

Form3.Show

End Sub

Private Sub Command2_Click()

Unload Form2

Unload Form3

Command2.Enabled = False

End Sub

Private Sub Command3_Click()

Dim f As Form

For Each f In Forms

Unload f

Next

End

End Sub

Private Sub Form_Load()

Command2.Enabled = False

End Sub

  • Tambah form2, dengan klik add form pada menu. Pilih item form kemudian open. Tambahkan 4 command button

Command1 = maksimais

Command2 = normal

Command3 = minimais

Command4 = tutup

Command5 = Lihat gambar

Command6 = >>

Command7 = gambar

Command8 = <<

Label1 = waw!

  • Ketikkan kode ini di form2:

Private Sub Command1_Click()

WindowState = vbMaximized

Label1.Enabled = True

Command5.Enabled = True

Command6.Enabled = False

Command7.Enabled = False

End Sub

Private Sub Command2_Click()

WindowState = vbNormal

Label1.Enabled = False

Command6.Enabled = True

Command8.Enabled = False

Form2.Height = 2910

Form2.Width = 4260

End Sub

Private Sub Command3_Click()

WindowState = vbMinimized

End Sub

Private Sub Command4_Click()

Unload Me

End Sub

Private Sub Command5_Click()

Form3.Show

End Sub

Private Sub Command6_Click()

Command7.Enabled = True

Form2.Width = 5265

Form2.Height = 2865

End Sub

Private Sub Command7_Click()

Form3.Show

Command6.Enabled = False

Command8.Enabled = True

End Sub

Private Sub Command8_Click()

Command6.Enabled = True

Command8.Enabled = False

Form2.Height = 2865

Form2.Width = 4275

Form3.Hide

End Sub

Private Sub Form_Load()

Label1.Enabled = False

Command8.Enabled = False

End Sub

  • Buat Form3, bikin image dan command button. Masukkan gambar dengan cara klik tanda […]. Kemudian keluar file browser. Cari gambar yang anda inginkan, lalu klik open.

Command1 = stop !

  • Ketikkan code ini di form 3:

Private Sub Command3_Click()

If Form2.WindowState = vbMaximized Then

Unload Form3

Else

Unload Form3

Form2.Height = 3480

Form2.Width = 3825

End If

End Sub

Private Sub Image1_Click()

MsgBox “ngapain sih..iseng banget”

End Sub

 

Referensi

  1. Student exercise series visual basic. Eazycom. Rahadian Hadi. Elex media komputindo
  2. Student guide series visual basic. Eazycom. Rahadian Hadi. Elex media komputindo

Stranger! SAY something here!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s