Archive for the ‘Non Insteon Programming’ Category

Here is a quick way that I reuse some of my lighting equipment depending on the season using individual components.   For example right now unless you order via the internet you can not find a good purple spot light.  And what I’ve experienced here in our FL weather many times your spot spike can rust and your investment is gone.

Also many of the spots are 100Watts which are real energy suckers and not to mention can get very hot.
So doing some searching and testing here is what I do.

Using a standard spike spot and cheap Daylight CFL bulbs, covered by a aluminum reflector and top it off with a colored lens. 🙂  Simple right?

Disclaimer: I am not a electrician and I only provide this info for entertainment, anything you do is at your own risk.

Here is the list
Light spike, Home Depot, and Lowe’s  and anywhere during holiday season  – $5-7
PAR 38 Spot aluminum reflector $4.25 each  *
1 PAR 36 Lens Cover you can get these at  $1.95
1 G/E Daylight 14 Watt bulb – (Walmart) 2 x $5  (Needs to be daylight not cool, bright or any other will not show the true color of the color lens)

Green Spray Paint.  To cover the outside of the reflector to hide its appearance.

* Note:You may spend a little up front for shipping ($5-7) but once you have your items you can reuse them over and over.  Only part which may need replacing would be the bulb
or the spike which you can find at any hardware store.
* Also the size o the  aluminum reflector that fits perfect is the one shown above, the site has many others but many dont fit (Trust me)
* Due to the size of the CFL’s, when building you may need to put lens last.

Very low power usage when using CFL’s.  For one traditional 100 Watts bulb you can use 6 of these spots. A++
Doesnt get very hot A++
Interchangeable parts, bulb goes out, swap the bulb and your set.  The spike/reflector/lens you can use over and over.
You‘ control the intensity adding the desired wattage bulbs.  If you lights are computer controlled you can even control dimmable CFL’s.

For me only one really, No really designed for outdoor use, I used clear shipping tape to secure the top lens and has worked fine so far from water getting in, of course I don’t turn on any decorations or lights if its raining.

Do a search for the following items in Amazon and pick your colors!

PAR 36 Red Plastic Lens
PAR 36 Yellow Plastic Lens
PAR 36 Amber Plastic Lens
PAR 36 Purple Plastic Lens
PAR 36 Blue Plastic Lens
PAR 36 Light Green Plastic Lens
PAR 36 Dark Green Plastic Lens

Here are some pics of the finished setup

Finished product with the outside of the reflector painted green.

Blue – Always perfect for Halloween cemetery




AMBER (Mix between Yellow and Orange another Halloween favorite)

Sorry forgot to take the pic of the Green one… 😦  Enjoy!

Just thought I’d post this little tidbit.  When using Flash/action script to call the infamous ‘Loadvariables’ functions I have found that some browsers like IE like to grab cached results, for some reason it worked fine in Firefox but if you try to embedded IE in your programs you will run into the same problems.

In my case I call the same function and the server side takes care of the action.  And if your like me you may be calling the same page more than once quickly.  This issue got me for days, and worked on some computers and other didn’t.

So when calling your pages just add a fictional variable not used by your pages, I called my cache_buster and add ‘date’ and ‘time’  to get a 8-15 character number that should be unique, tricking the browser you are looking for a unique page and not grab from cache

loadVariables(""+new Date().getTime(), this);

If your like me who use Firefox on a daily basis most of your browsing.  You know it can be frustrating when you hit a Internal Sharepoint servers or a box which assumes your running IE and depends on NTLM, In our case as you know each time it will ask for your domain user-name / password.  We’ll Firefox does have NTLM just that you need to configure it which is really specify the boxes you will connect to.  Hey its not fully automatic but in my case works like a charm since I don’t connect to 1000 Sharepoint boxes.

NTLM stands for NT Lan Manager, but not the ol’ Lan manager software but instead Microsoft’s authentication protocol.    (These changes are done at your own risk)

Here we go, First launch Firefox and enter in the URL; about:config

This will expose all Firefox’s system settings

From there it will provide a long list of settings, on the ‘search’ bar type NTLM, you will see 3 entries, were just interested in one.

Double click on network.automatic-ntlm-auth.trusted-uris

From there you will enter the DNS name of your Server, in this case a Sharepoint server, since I only have one server Im suspecting you can enter more than one with a comma.

And presto, close firefox and re-open…

For email coming in and out, I use MS outlook, which makes interfacing with VB very easy.  But if you have configured the outlook client not using exchange, you know that you must specify the time in minutes it will poll to check for email.  Lets say you want to force it to check for new-email at your will.  Well this is how its done, but for this to work you must have the outlook client open.

If you havent please jump this article which shows how to setup your references and other goodies prior to this.

Software:Controlling Insteon devices using an email account

Back here so soon, great!

What are are doing is calling the Microsoft core command bar of the application itself and ‘press’ the button we want to execute, in this case

Were creating instances of the Controls, Tools – > Send/Receive and the account we want to poll. And I don’t have to wait for the application to hit its internal timer.
Sure you can let the timer run but in my case I have my MX records pointing home and host my own pop3 server, so once I get email I notify my server program (In another article soon) to force a scan of my email and act accordingly.  This makes the response to my emails lighting fast.!

So here’s the code,

Function ForceEmailcheck() as boolean

        '------------ Set up the Variables / Objects
        Dim oCtl As Microsoft.Office.Core.CommandBarControl
        Dim oPop As Microsoft.Office.Core.CommandBarPopup
        Dim oCB As Microsoft.Office.Core.CommandBar

        'Use the Send/Receive on All Accounts action in the Tools
        'menu to send the items from the Outbox, and receive new items for my specific account
        oCB = objOutlook.ActiveExplorer.CommandBars("Menu Bar")
        oPop = oCB.Controls("Tools")
        oPop = oPop.Controls("Send/Receive")
        oCtl = oPop.Controls.Item(6)   '----- Please see below why this is a #6 (*)

        '------ return something but not needed to work
        ForceEmailCheck = True
    End Function

* Since your this calls the name of the account itself for example ( you will need to use that name for this to work, so I ended up using the item # and its easier.
The way to find this out is after you have set up your outlook, copy the above code in your VB and

set a break point at "oPop = oPop.Controls("Send/Receive")"

Then from your ‘Immediate window’ in VB do a query of the item of that control to see where your ‘send/receive’ for your specific account is, (Most likely #6 also)

?oPop.Controls.Item(4)... etc...

Until you find the item you wish to ‘press’ and then insert the # above.    That is how I found the item I was looking for was #6.

And your Set!!


One of the questions ive been asked is how to I put my flash script to grab data from the SQL database and provide updates if the device is on or off etc.

Well the awnser is, I dont. Like mentioned before to have your flash talk directly to a sql database you will need additional components which I dont want to install $$$, such as cold fusion or some advanced Flash stuff.  Again I want speed and functionality, especially if its only for a few users.

So what I did was use a internal web server which is installed with VB 2008, to do all the talking for me, more like a middle man.  for example my flash program talks to this web page using the ‘load’ function which sends data using the POST commands (example and the code runs and returns the values needed in a specific variable in this case ‘VALUE’. you can also use the LoadVariables command which explain that in this article.

Flash:Loading Variables from files into Flash

So here is a high level of what is being done in the background.

All all times the Insteon Server is updating the SQL Server with the status of the devices as they are turned on or off, so we dont need to connect there. Also note that the Local .net, SQL database and insteon server are all on the same box!

For example lets say I want to pull the status of device #14. (Fan in master bedroom)  This is what I would do from the Flash Program

Example in FLASH CLIENT;

Prepare: In Flash you will need to create a empty movie clip called ‘fan_master’.  Also have images already in your webpage in the location mentioned below. I call it right of the same page you can use your local library if you like.

Here are my images I use in my Flash program,  you may use them if you like (Just right click on them and use SAVE AS)



Off Button (small_button_on.png)

On Button (small_button_off.png)

In my actionScript, I would put on one of the frames;

var mfan:LoadVars = new LoadVars();
    mfan.onLoad = function() {

//------ Here I check the return value that is returned back as 'value' if its is ON then replace the fan_master 'movie' to the bulb on image
          if (mfan.value=="ON"){
            loadMovie("", fan_master);
        } else {
            loadMovie("", fan_master);
//---------------- do the actual opening of the webpage and pass the variable IN and the device im asking for


A description of my Devices Database is found here

‘————————— VB 2008 / WEBPAGE filename finddata.aspx

On my Server side I would grab the value on “IN” using the

 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      '------- Device will hold the value of in 'IN' which is #14
      device = Context.Request.Params("IN")
      value = Lg_Get_Device_Status(device)
      Response.Write("value=" + value)
 End Sub

This will return to my program the following text
“value=ON” or “value=OFF”

‘——– Function to grab the device data by the device #

    Public Function Lg_Get_Device_Status(ByVal Marker As String) As String

        Dim sqlConnection10 As New System.Data.SqlClient.SqlConnection(ConnectionSTring) ' Set your connectionstring accordingly.
        Dim Cmd10 As New System.Data.SqlClient.SqlCommand

        '-------- We'll use the SqlDataReader to get the values of the table 
        Dim Reader As SqlClient.SqlDataReader

        Cmd10.CommandText = "SELECT * FROM Devices where Marker= '" + Marker + "'"
        Cmd10.Connection = sqlConnection10
        Reader = Cmd10.ExecuteReader()

        ' check for data, if not return 'FALSE'
        If Reader.HasRows = False Then
            Lg_Get_Device_Status = False
            Exit Function
        End If
        Lg_Get_Device_Status = Reader.Item("status")

    End Function

And there you have it, I do use the same file (finddata.aspx) for other stuff and you can easily query what is being passed and eventually act on it like this,

For example if I pass(showall=1) it would run another function, but that is another article.

        '------------------- SHOW ALL DEVICES
        If Context.Request.Params("showall") <> "" Then Show_insteon_devices() : Exit Sub

        '------------------- SHOW ALL DEVICES by MAC address
        If Context.Request.Params("showmacs") <> "" Then Show_insteon_devices_mac() : Exit Sub

        '------------------- SHOW ALL CONFIGS
        If Context.Request.Params("show_all_configs") <> "" Then Show_all_configs() : Exit Sub

In trying to consolidate all the PC’s and other OS I have at home into one machine I ran into a small problem.  First I was finally able to remove my good old 2k3 test server.  This server hosted Exchange, DNS, DHCP, and 5 webpages.  With that said, the pc replacing it only had XP on it and really was going to let my trusty D-link take care of DNS,DHCP and all the other goodies.  And I had no need to exchange

But once I came to migrate my webpages, XP’s IIS only allows you to run one webpage!?.  Ok np, all my webpages are PHP,MySql and other goodies so I really had no need for IIS nor .NET framework.  So I downloaded a copy of XAMP which has everything ready to go.  You can find that here.  This package includes

Apache, MySQL, PHP + PEAR, Perl, mod_php, mod_perl, mod_ssl, OpenSSL, phpMyAdmin, Webalizer, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, Ming, JpGraph, FileZilla FTP Server, mcrypt, eAccelerator, SQLite, and WEB-DAV + mod_auth_mysql.

Its more than all the necessary tools in one easy to use program, and since all its components are free well its free for you to.

Go ahead and install it, you’ll have your webpage setup in no time!.  Lets say you have your router allowing port 80 out to the internet so you want to host more than one page (I’ll explain the port opening on another document).

For the example I have one page pointed to and on the same XP in windows

  • Install Xamp and test you can see the webpage.  In my case I installed it on F:\ drive which we’ll use from now on, you can use C:\ if you like. Coming for the server side, I keep my system files separate from the program files.
  • Look for your apache http.conf file, in my  case it was found here “E:\xampp\apache\conf”, open it with notepad.  Were going to give Apache permissions to the webpage root folder first.

Add the following lines in this case my files are located on E:/shared/WebSite-Live/site1_files and the second site on Site2_files

<Directory "E:/Shared/WebSites-Live/site1_files">
  Order allow,deny
    Allow from all

<Directory "E:/Shared/WebSites-Live/site2_files">
  Order allow,deny
    Allow from all

For the sake of simplicity we’ll allow All to view this folder.

  • Now we are going to go ahead and create the virtual host.  Look for this file called ‘httpd-vhosts.conf’ this can be part of the original http.conf file but is separated in the install of xamp , so we will modify that file directly, that is found ‘e:\xamp\apache\conf\extra’. Go ahead and open it with Notepad
#'---------The first section we will leave alone since its the main page, and will only load from the localhost
 DocumentRoot "e:/xampp/htdocs"
 ServerName localhost
 ServerAlias localhost
<VirtualHost *>
 DocumentRoot "e:/Shared/WebSites-Live/site1_files"
 <Directory "e:/Shared/WebSites-Live/site1_files">
 Options All Includes Indexes
<VirtualHost *>
 DocumentRoot "e:/Shared/WebSites-Live/site2_files"
 <Directory "e:/Shared/WebSites-Live/site2_files">
 Options All Includes Indexes
  • Either using the Xamp console or going to control panel then services restart your Apache service and your set!

Note: If your not exposing your Pc out into the internet you can still host more than one site, you may need to play with each PC’s ‘hosts’ file to point them to the PC hosting the sites.

Hi, in a previous article I had shown how to monitor & capture data on a specific port using VB. Mainly to allow my server send out notification to the clients, like a Caller ID Alert. That article can be found here

How to monitor and capture data in a specific port in VB / 2005

Below I’ll show the code I use on the server side to actually open and send the information to the clients.

Like mentioned above I will use the example of a caller Id alert , so the program will open a port 81 and send the text ‘callerid’ to the clients (In this case You can use PC names if you have a home router like D-link etc.

Since I have a couple of clients I use VB ‘commandline’ feature to retrieve the IP, port and message that I am going to send.  My utility is called ‘BumpClients’.  For the example lets say this how its called

“Bumpclients.exe callerid 81”

—————— Setting up the imports, make sure you include System.Net and, the others may not be needed

Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Imports System.Xml.XPath
Imports System.IO
Imports System.Net
Imports System.Net.Sockets
Imports System.Data
Imports System
Imports System.Drawing
Imports System.Windows.Forms

Public Class Form1

'------------------------------ Create the instance to of the TCP Client (Its the same as receiving)
    Public WithEvents OpenPort As TcpClient  

'------ I use the Form_load event to quickly send the message and exit the program, no user interaction is needed, we grab all paramters from the command line when called.
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.WindowState = FormWindowState.Minimized '- Go hidden
        Me.Hide() '- Go hidden

'------ Next using the Split command I grab the three parameters by looking for the space( This will give me the IP,the command,and port the program will use!)
'------ Data(0)=IP, Data(1)=command, Data(2)=port.

        Dim IP As String
        Dim datA_out
        Dim port As Integer

        data_out = Split(Command$(), " ")
        IP = data_out(0)
        port = data_out(2)

'------ Just a quick check to make I can ping the IP, if not just exit and dont even bother.
        If My.Computer.Network.Ping(IP) = False Then End

'---- The actualy opening of the port un a 'try' statement if it fails exit also
            OpenPort = New TcpClient(IP, port)
        End Try

'------ If all is good then go ahead and convert our text to bytes and send it out using the stream method!
       Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes(Trim(data_out(1)))

        Dim stream As NetworkStream = OpenPort.GetStream()
        stream.Write(data, 0, data.Length)

'------ Close and exit!- That's it!
    End Sub
End Class

A important note, remember that on your client you need to open the port you use in the firewall or it will never see anything, but you dont need to open it on the server since it will be sending.  To test this you will need the two actual computers sine you cant monitor and send data thru the same port.

In my application I actually run a external program using the system.diagnostics,process.start command, to the IP of my PC’s this way, it will run each script and not wait.And each of time will exit accordingly.


System.Diagnostics.Process.Start(“C:\vb\Insteon_BumpClients\BumpClients\BumpClients\bin\Release\BumpClients.exe”, ” ” + data_out + ” ” + port) ‘ Laptop
System.Diagnostics.Process.Start(“C:\vb\Insteon_BumpClients\BumpClients\BumpClients\bin\Release\BumpClients.exe”, ” ” + data_out + ” ” + port) ‘
System.Diagnostics.Process.Start(“C:\vb\Insteon_BumpClients\BumpClients\BumpClients\bin\Release\BumpClients.exe”, ” ” + data_out + ” ” + port) ‘


For my voice mail / Caller-ID function I placed the name / number of the person in a database but also I have the name of my contact (joe.png, luis,jpg etc), After Ive retrieved the information, I FTP back to the server to grab the image file

Here is how its done.

For the example;

FTP server is at

username is :webuser
password is :password
File to get: <variable called ImageName> in a folder called Images
Location to save: c:\images\<ImageName>
The default folder on my server have a folder called images/

On the server im running FileZilla FTP Server (Free)


Imports System.Net
Imports System.Net.Sockets
Imports System.IO
Public Function GetFTP(ByVal ImageName As String)
        Dim localFile As String = "c:\images\" + ImageName
        Dim remoteFile As String = "/images/" + ImageName
        Dim host As String = ""
        Dim username As String = "webuser"
        Dim password As String = "password"
           '1. Create a request: must be in ftp://hostname format, 
            Dim URI As String = host & remoteFile
            Dim ftp As System.Net.FtpWebRequest = _
            CType(FtpWebRequest.Create(URI), FtpWebRequest)

            '2. Set credentials
            ftp.Credentials = New _
            System.Net.NetworkCredential(username, password)
            '3. Settings and action

            ftp.KeepAlive = False

            'we want a binary transfer, not textual data
            ftp.UseBinary = True

            'Define the action required (in this case, download a file)
            ftp.UsePassive = False
            ftp.Method = System.Net.WebRequestMethods.Ftp.DownloadFile
           'Loop to read & write to file

            Using response As System.Net.FtpWebResponse = CType(ftp.GetResponse, System.Net.FtpWebResponse)
                     '-----Setup Response stream to grab the FileStream aka Data and send it to a file using the FileStream object.
                Using responseStream As IO.Stream = response.GetResponseStream                         
                    Using fs As New IO.FileStream(localFile, IO.FileMode.Create)
                        Dim buffer(2047) As Byte
                        Dim read As Integer = 0
                        '-----Once Data is detected in the ResponseStream Loop until empty,
                            read = responseStream.Read(buffer, 0, buffer.Length)
                            fs.Write(buffer, 0, read) '----- Write the 'read' variable into the file
                        Loop Until read = 0 

                    End Using
                End Using
            End Using

Exit function


In one of my  previous post I had shown how to capture the Caller Id info of a modem.  So what do I do this the information??

In my case I notify all the PC in the house a particular caller / number is ringing by sending data on a specific port.  So they know who it is before picking up or even looking at the phone for the caller Id info. Below is the code on how to monitor a port for data.

In this case it will open and monitor port 81.  Since there is no event for the TCPListener Im using the VB timer control, then check the port for any pending data ever 1000ms , if data is pending it will read it and show it in a pop-up in the icon tray. 🙂

To keep it simple here, and Not shown here, I actually FTP back via code (Will setup another post for this) to the server and grab the image of the person which is then displayed on the client on another window.

Like all code here, is all in VB 2005. For setup: Note that for this  to work you do need to open port 81 (TCP) on the client.

Just create a basic form with the following controls (All are default names)

A Notify object called “NotifyIcon1”
A timer object called “Timer1”

‘—————— setup my Import variables, some may not be needed.

Imports System.Web
Imports System.Net
Imports System.Net.Sockets
Imports System.IO
Imports System
Imports System.ComponentModel
Imports System.Threading
Imports Microsoft.VisualBasic

'----------------------- Here is the main class which loads the form.
Public Class Form1
    Public WithEvents OpenPort As TcpListener '--------- I setup the TCPListner object, There really isnt no events for it so I have to check using a timer.

'--------- GET THE CLIENT ip FROM THE ENVIRONMENT This will return ina array the IP of the client in the case of XP the first ip(0) should be fine, in the case
'--------- vista you have to search for it. I just looked for the first octet to be the same as my internal network.

    Public ip() As System.Net.IPAddress = System.Net.Dns.GetHostEntry(Environment.MachineName).AddressList
    Public IPAdresstxt As String

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'ip(0) = IPAddress.Parse(Microsoft.VisualBasic.Interaction.Command()) '---- Un-comment for XP

'------- for Vista the first item of the array can be anything, so I loop thru the values looking for the same network of my home network
        Dim ip_count As Integer
        or ip_count = 0 To ip.Length - 1
            If ip(ip_count).ToString.Contains("192") = True Then
                OpenPort = New TcpListener(ip(ip_count), 81)  '--------- Here we set the IP (My PC) and the port to monitor in this case 81
                IPAdresstxt = ip(ip_count).ToString
            End If

        OpenPort.Start() ' - Open and monitor
        NotifyIcon1.Visible = True
        NotifyIcon1.BalloonTipTitle = "Caller ID"
        NotifyIcon1.BalloonTipIcon = ToolTipIcon.Info
        NotifyIcon1.BalloonTipText = "Caller ID Running, window will close in 3 seconds"
        NotifyIcon1.ShowBalloonTip(2500)  '----------------- Hide my Icon popup after 2500 MS
        Me.Hide() '----------- This will hide my form and only leave the icon on the tray.  :)

    End Sub

'------------------ This is my main timer1 which is enabled and checked every 1 sec.
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        '-------------- CHECK PORT 81 IF GOT DATA
        If My.Computer.Network.IsAvailable = True Then  '----- If data is present then read data and pharse it.
            If OpenPort.Pending = True Then
                Dim bytes(1024) As Byte
                Dim data As String = Nothing
                Dim client As TcpClient = OpenPort.AcceptTcpClient()
                Dim stream As NetworkStream = client.GetStream()
                Dim i As Int32
                ' Loop to receive all the data sent by the client.
                i = stream.Read(bytes, 0, bytes.Length)
                While (i <> 0)
                    data = data + System.Text.Encoding.ASCII.GetString(bytes, 0, i)
                    data = data.ToUpper()
                    Dim msg As Byte() = System.Text.Encoding.ASCII.GetBytes(data)
                    i = stream.Read(bytes, 0, bytes.Length)
                End While

                data = LCase(data).Trim
                ShowCallerID(data)  '---------------------- Call the function to update the Notify-Icon
                Msgbox "Data received is"+data
         End If
        End If
    End Sub

'---------------------- Function to update the Notify-Icon
    Public Function ShowcallerID(number as Integer) As Boolean
        NotifyIcon1.BalloonTipText = "Incomming call from " + name + vbCrLf + " From # " + number.ToString
        IncommingCallWindow.txtName.Text = name
        If number.ToString.StartsWith("1") = True Then
            number = Val(Mid$(number, 2, number.ToString.Length - 1))
        End If

    End Function

End Class


Here is another good tip which you may find helpfull.

Lets say you want to control the Monitor’s power state (On/Standby) via VB.

In my case, my Den holds my wife’s and my computer.  The program already (using the before mentioned X10 sensors) detects movement after sunset it will ‘talk’ the weather of two zip codes (Home and work) but I would like it also to ‘bring’ back the computer from its monitor power saving mode, so even before I touch the mouse, the computer is waiting for me.
Basically the code does is calls directly to the User32 library (like to good old VB6 days).    In case we will alter the SC_MONITORPOWER state from -1, to 0, and calling other System values in HEX.

Below is how its done in VB 2005 / .NET,
is the same thing but in “C” code, I basically converted it from here.


1st we will define the Function that will be called,

2nd We will define 2 subroutines or functions that we can call I called them “WakeUp” and “Sleep.

Again this only consist of the monitor ‘power’ state, the computer is not on standby or hibernation. Many of today’s computer now have WOL capability BUT only for wired (Cat 5) connections, in my case I use USB wireless all around the house and I haven’t gotten that part to work yet.

Code below,

Public Class Form1

    '-------------- FUNCTION TO WAKE UP SCREEN
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

    Dim WM_SYSCOMMAND As Integer = &H112
    Dim SC_MONITORPOWER As Integer = &HF170
    Dim HWND_BROADCAST As Integer = &HFFFF

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

                 ... all your startup code here...

 Public Sub Wakeup()

        Beep() '---- Just for fun
    End Sub

    Public Sub Sleep()
    End Sub