Turn Insteon Devices On and Off with Visual Basic 6
Make sure you have already followed the instructions to Add Insteon Support to Visual Basic.
You should already have the following code:
Dim WithEvents sm As SDM3
Private Sub Form_Load()
' create a new instance of the SDM
Set sm = New SDM3Server.SDM3
' this sub will be called when the
' PLC receives an Insteon Event
Private Sub sm_OnText(ByVal Text As String)
Now we are going to add a command button, and put the command to turn a light on to 100% brightness:
Private Sub Command1_Click()
' tell the device to turn on
sm.SetOnLevelText "07.B1.12", "100%"
The function SetOnLevelText is used to turn a device on and off. Simply pass the device ID as the first parameter, and the desired level as the second parameter, followed by the % sign.
You are now ready to create a project that will control the Insteon in your house using Visual Basic.