Postingan Kali ini saya akan memberikan cara membuat lampu kelap kelip menggunakan VB.NET nah langsung aja ni cara-cara membuatnya
1. Membuat Form Baru dengan Klik Poject- Add Windows Form
2. Menambahkan komponen komponen Button,Label dan Timer
3. Mengisikan Propertinya seperti :
4. kemudian masukan kode berikut ini,
Public Class Form5Dim Milsecond As Integer = 0Dim seconds As Integer = 0Dim HalfSecond As Integer = 0Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadLabel1.BackColor = Color.VioletLabel2.BackColor = Color.VioletLabel3.BackColor = Color.VioletLabel4.BackColor = Color.VioletLabel5.BackColor = Color.VioletLabel6.BackColor = Color.VioletTimer1.Start()End SubPrivate Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick'terpaut o,5 detikMilsecond = Milsecond + 1If Milsecond = 5 Or Milsecond = 15 And Label1.BackColor = Color.Violet ThenLabel1.BackColor = Color.YellowLabel2.BackColor = Color.VioletElseIf Milsecond = 10 Or Milsecond = 20 And Label2.BackColor = Color.Violet ThenLabel1.BackColor = Color.VioletLabel2.BackColor = Color.Yellow'terpaut 1 detikseconds = seconds + 1If seconds = 1 And Label3.BackColor = Color.Violet ThenLabel3.BackColor = Color.YellowLabel4.BackColor = Color.VioletElseIf seconds = 2 And Label4.BackColor = Color.Violet ThenLabel3.BackColor = Color.VioletLabel4.BackColor = Color.Yellow'terpaut 2 detikIf Label5.BackColor = Color.Violet ThenLabel5.BackColor = Color.YellowLabel6.BackColor = Color.VioletElseLabel5.BackColor = Color.VioletLabel6.BackColor = Color.YellowEnd Ifseconds = 0End IfEnd IfIf Milsecond = 20 ThenMilsecond = 0End IfEnd SubEnd Class
ini dia hasil progam yang telah dibuat
Tidak ada komentar:
Posting Komentar