X10 Community Forum
🖥️ActiveHome Pro => SDK => Topic started by: kyleg on October 11, 2008, 01:01:53 PM
-
been trying for weeks to get CM15A to work with VB6. Even tried VB2008 and no luck.
anybody have an example or source file that I could see? The VB folder with the SDK was blank and did not have any examples. I have combed through this forum and tried them all and no luck. Would prefer VB6
here is what I was trying as a simple test to just turn on A1 when the form loads
VB6
' load form and trigger
Private Sub form1_Load()
ActiveHomeObj = New ActiveHome
ActiveHomeObj.SendAction("sendplc", "A1 on")
End Sub
.....or V2008
' load form and trigger
Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ActiveHomeObj = New ActiveHome
ActiveHomeObj.SendAction("sendplc", "A1 on")
End Sub
Can anyone shoot of some code or a URL with an example?
Thanks
-
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
-
thanks...I'll give this one a try as well as well as the other in the previous post
-
Thanks hkactive ,
This worked. It looks like it needs Private Sub myCM15_RecvAction even if you are only sending. I thought that was for monitoring or recieving imputs but seems to need it for send commands to work. .......and also the
"Option Explicit
Private WithEvents myCM15 As ActiveHome"
which I had but a little different. I will post in other thread the final that I trimed down to get the bare minimum lines of code to send a command. maybe comment each line for othe newbies
Thanks again!!!