# Visual Basic > Games and Graphics Programming > Game Demos >  some logic of begginers

## abubasil

hi all
its me , the novice programmer.
see this on off light bulb .

----------


## 4x2y

Nice work, but here is a compact and easy to understand code


```
Option Explicit
Private mblnMainSwitch As Boolean
Private mblnLightSwitch As Boolean

Private Sub Form_Load()
    mblnMainSwitch = False
    mblnLightSwitch = False
    SetLight
End Sub

Private Sub Command1_Click()
    mblnMainSwitch = Not mblnMainSwitch
    SetLight
End Sub

Private Sub Command2_Click()
    mblnLightSwitch = Not mblnLightSwitch
    SetLight
End Sub

Private Sub SetLight()
    Command1.BackColor = IIf(mblnMainSwitch, vbYellow, vbWhite)
    Command1.Caption = "Main Switch " & IIf(mblnMainSwitch, "ON", "OFF")
    
    Command2.BackColor = IIf(mblnLightSwitch, vbYellow, vbWhite)
    Command2.Caption = "Light Switch " & IIf(mblnLightSwitch, "ON", "OFF")
    Image1.Picture = IIf(mblnMainSwitch And mblnLightSwitch, LoadPicture(App.Path & "\" & "on.jpg"), LoadPicture(App.Path & "\" & "off.jpg"))
End Sub
```

----------


## abubasil

Gee thanks
I am here for such "kind enlightenment".
Your post is equal for dozens of lessons for me.
I will be grateful if you have a glance at my other posts.

----------


## 4x2y

> I will be grateful if you have a glance at my other posts.


What post you are talking about?

----------


## abubasil

Oh sorry it is one post not posts
http://www.vbforums.com/showthread.p...emo-simple-one
that if it is worthy and opens new opportunities for beginners like myself to learn how to handle code..I mean give it a slight push.

thank you

----------

