05
Jun
09

vb dasar.. pengambilan nilai suatu object

download aplikasi timer shutdown

halo brow, sebelumnya aku minta sorie cos, untuk aplikasi timer lom ku upload. Tapi kali ini aku mau berbagi secara dasar dulu tentang vb. Kali sederhana sich tapi pengembanganya bisa luar biasa. Hehehe… langsung aja, lihat skrip dibawah ini :

Private Sub Timer1_Timer()

a.Caption = a.Caption + 1

If b.Caption = a Then

b.Caption = b

Else

If b.Caption = b Then

b.Caption = c

Else

If b.Caption = c Then

b.Caption = d

Else

If b.Caption = d Then

b.Caption = e

Else

If b.Caption = e Then

b.Caption = f

Else

If b.Caption = f Then

b.Caption = a

Else

End If

End If

End If

End If

End If

End If

c.Caption = c.Caption + 1

c1.BackColor = a.Caption + b.Caption + c.Caption

If a.Caption = 99 Then

a.Caption = 0

b.Caption = a

c.Caption = 0

End If

End Sub

Dan gambarnya sebagai berikut.

form ubah warna

Keterangan : berturut turut dari atas yang berada didalam form yaitu : command dengan name c1, label dengan name a, a, dan c. dengan nilai property awal :

C1 :

style = graphical
Backcolor = &H00FFFFFF&

a caption = 0

b caption = b

c caption = 0

Bagi yang sudah expert mungkin ngomel.. halah gitu aza.. tapi menurutku ini bagus banget coz ini metoda pengambilan nilai dari suatu objek. Dan dimasukkan kedalam property dari atribut warna command.

Private Sub Timer1_Timer() //timer untuk counter program

a.Caption = a.Caption + 1 // menambah nilai dari caption a dengan satu secara simultan

If b.Caption = a Then //merubah caption nilai a dengan b

b.Caption = b

Else

If b.Caption = b Then //setelah caption menjadi b dirubah ke c

b.Caption = c

Else

If b.Caption = c Then // dan seterusnya

b.Caption = d

Else

If b.Caption = d Then

b.Caption = e

Else

If b.Caption = e Then

b.Caption = f

Else

If b.Caption = f Then

b.Caption = a //sampai dirubah ke a lagi

End If

End If

End If

End If

End If

End If

c.Caption = c.Caption + 1 //meruhan nilai caption a dengan ditambah satu secara simultan

c1.BackColor = a.Caption + b.Caption + c.Caption //merubah backgroundc1 melalui perubahan diatas

If a.Caption = 99 Then // fungsi even handling untuk caption masig-masing

a.Caption = 0

b.Caption = a

c.Caption = 0

End If

End Sub

Pertanyaan :

  1. Kenapa a = 0 , b = a dan c =0 ?
  2. Kenapa variable b hanya sampai f percabanganya?

Jawab :

  1. Ini untuk variasi warna yang dihasilkan dari kombinasi

c1.BackColor = a.Caption + b.Caption + c.Caption

dengan handling untuk errornya

If a.Caption = 99 Thena.Caption = 0

b.Caption = a

c.Caption = 0

End If

End Sub

  1. Karena angka b untuk pengambilan nilai warna menggunakan hexa decimal yang hanya maksimal f.

Program diatas sebagai contoh untuk pengembangan logika dan teknik yang belum diketahui.. dan aku mohon sharing dari komentarnya. Dan aturan perubahan warna terserah.

Untuk download source project disini


0 Responses to “vb dasar.. pengambilan nilai suatu object”



  1. No Comments Yet

Leave a Reply




Blog Stats

  • 30,442 hits

MY PERSONAL LINK

 

June 2009
M T W T F S S
« Apr    
1234567
891011121314
15161718192021
22232425262728
2930  

00WEBHOST

Free Website Hosting

RSS Unknown Feed

  • An error has occurred; the feed is probably down. Try again later.