How to make a Strobe light program in VB.NET

Strobe Light described in this tutorial is designed for slow motion photography, if you don't have access to a physical strobe light or you can't afford one or don't have the materials to make one, you can still make one with the help of programming languages.

The strobe program described here, has an adjustable frequency of upto 5 milliseconds (Actually my computer couldn't manage it below that frequency) and you can choose only one flash color for your strobe.

Remove these adsRemove these ads by Signing Up

Step 1: Let's Setup our environment first

Picture of Let's Setup our environment first

I coded the strobe in express 2010, the same code would work for vb 2008 and above,

Open Visual Basic and create a new windows form application, then add a 'colordialog' from toolbox to the form it should drop below the form because it works in the background, then add a trackbar, two 'timer's', two 'button's' and 'textbox', Name one of the buttons as choose color and it's name as 'button1' and keep the text property of other button blank , name the blank button 'btn'.

and also add another form to the application; set it's FormBorderStyle to none and WindowState to 'maximised'.

Now the design is complete, So let's move to next step.

Step 2: Let's Code

Now, when our design is done, lets make it alive with code.

Lets begin with the trackbar, double click on the trackbar trackbar1_scroll sub is automatically generated, now type the following code in the sub;

        Timer1.Interval = TrackBar1.Value<br>        Timer2.Interval = TrackBar1.Value
        TextBox1.Text = TrackBar1.Value

Now double click the 'choose color' button, and type the following code in the respective sub;

        ColorDialog1.ShowDialog()<br>        Form2.BackColor = ColorDialog1.Color

Now double click the blank button, and type the following code in the respective sub;

If Btn.Text = "On" Then<br>            Btn.Text = "Off"
        ElseIf Btn.Text = "Off" Then
            Btn.Text = "On"
        End If

Now double click the form1 head and type the following code in the form1_load sub;

Btn.Text = "Off"

Now finally type the following code in timer1 tick event;

Form2.BackColor = ColorDialog1.Color<br>        Timer1.Enabled = False
        Timer2.Enabled = True

And the below code in timer2 tick event;

Form2.BackColor = Color.White<br>        Timer1.Enabled = True
        Timer2.Enabled = False

Now type the following code in the form2's load event;

Me.BackColor = Form1.ColorDialog1.Color
rimar200010 months ago

Very clever solution. Never I thought it.

MYawar (author)  rimar200010 months ago