Add the reference for the Active Home Script 1.0 type library. You should have already run the ahsetup.exe file from the Active Home SDK so that this library is available to Visual Basic 6.
The following code is for 1 standard form. You'll need one Command Button named cmdSwitch and two Option Buttons (optState(0), optState(1)). You can add code in the myCM15_RecvAction to respond to motion sensors, etc.
Option Explicit
Private WithEvents myCM15 As ActiveHome
Private Sub cmdSwitch_Click()
On Error GoTo SWITCH_ERROR
With myCM15
If optState(0).Value = True Then
.SendAction "sendplc", "b1 off"
Else
.SendAction "sendplc", "b1 on"
End If
End With
Exit Sub
SWITCH_ERROR:
Debug.Print Err.Description, Err.Number, Err.Source
End Sub
Private Sub Form_Load()
Set myCM15 = New ActiveHome
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set myCM15 = Nothing
End Sub
Private Sub myCM15_RecvAction(ByVal bszAction As Variant, ByVal bszParm1 As Variant, _
ByVal bszParm2 As Variant, ByVal bszParm3 As Variant, ByVal bszParm4 As Variant, ByVal bszParm5 As Variant, ByVal bszReserved As Variant)
Debug.Print bszAction, bszParm1, bszParm2, bszParm3, bszParm4, bszParm5, bszReserved
End Sub