Friday, July 6, 2012

Program 7 segment visual basic

Di siang hari yang amat sangat terasa sangat panas ini,hehe,,, saya akan memberi tutorial program 7 segment mengggunakan visual basic 6.0. Cara kerja dari program ini sangat sederhana, yaitu apabila kita menekan tombol antara 1 s/d 0, contohnya kita menekan tombol '2' maka akan muncul no 2. sangat sederhana bukan???
langsung ke tutorial-nya.
1. buka vb
2. pilih standard exe

3. lalu masukkan komponen-komponen dibawah ini.

4. lalu susun komponen-komponen tersebut sepert gambar dibawah ini.

5. Klik view code pada jendela project dan pastekan code dibawah ini.

Private Sub Command1_Click()
Shape4.FillColor = vbRed
Shape5.FillColor = vbRed
Shape6.FillColor = &H8000000C
Shape2.FillColor = &H8000000C
Shape8.FillColor = &H8000000C
Shape3.FillColor = &H8000000C
Shape7.FillColor = &H8000000C
End Sub

Private Sub Command10_Click()
Shape6.FillColor = vbRed
Shape2.FillColor = vbRed
Shape3.FillColor = vbRed
Shape7.FillColor = vbRed
Shape5.FillColor = vbRed
Shape4.FillColor = vbRed
Shape8.FillColor = &H8000000C
End Sub

Private Sub Command2_Click()
Shape6.FillColor = vbRed
Shape4.FillColor = vbRed
Shape8.FillColor = vbRed
Shape3.FillColor = vbRed
Shape7.FillColor = vbRed
Shape2.FillColor = &H8000000C
Shape5.FillColor = &H8000000C
End Sub

Private Sub Command3_Click()
Shape6.FillColor = vbRed
Shape4.FillColor = vbRed
Shape8.FillColor = vbRed
Shape5.FillColor = vbRed
Shape7.FillColor = vbRed
Shape2.FillColor = &H8000000C
Shape3.FillColor = &H8000000C
End Sub

Private Sub Command4_Click()
Shape4.FillColor = vbRed
Shape8.FillColor = vbRed
Shape2.FillColor = vbRed
Shape5.FillColor = vbRed
Shape6.FillColor = &H8000000C
Shape3.FillColor = &H8000000C
Shape7.FillColor = &H8000000C
End Sub

Private Sub Command5_Click()
Shape6.FillColor = vbRed
Shape2.FillColor = vbRed
Shape8.FillColor = vbRed
Shape5.FillColor = vbRed
Shape7.FillColor = vbRed
Shape3.FillColor = &H8000000C
Shape4.FillColor = &H8000000C
End Sub

Private Sub Command6_Click()
Shape6.FillColor = vbRed
Shape2.FillColor = vbRed
Shape3.FillColor = vbRed
Shape7.FillColor = vbRed
Shape5.FillColor = vbRed
Shape8.FillColor = vbRed
Shape4.FillColor = &H8000000C

End Sub

Private Sub Command7_Click()
Shape6.FillColor = vbRed
Shape4.FillColor = vbRed
Shape5.FillColor = vbRed
Shape8.FillColor = &H8000000C
Shape7.FillColor = &H8000000C
Shape3.FillColor = &H8000000C
Shape2.FillColor = &H8000000C
End Sub

Private Sub Command8_Click()
Shape6.FillColor = vbRed
Shape2.FillColor = vbRed
Shape3.FillColor = vbRed
Shape7.FillColor = vbRed
Shape5.FillColor = vbRed
Shape8.FillColor = vbRed
Shape4.FillColor = vbRed
End Sub

Private Sub Command9_Click()
Shape6.FillColor = vbRed
Shape2.FillColor = vbRed
Shape4.FillColor = vbRed
Shape8.FillColor = vbRed
Shape5.FillColor = vbRed
Shape7.FillColor = vbRed
Shape3.FillColor = &H8000000C
End Sub

6. Setelah selesai, jalankan program dan hasilnya akan tampak seperi gambar dibawah ini.

semoga bermanfaat,,,,
:D



No comments:

Post a Comment