Please login or register.

Login with username, password and session length
Advanced search  

News:

The X10Hub (PiX10Hub) is here! Created by the Community, for the Community.:)% #:)

Author Topic: anybody get CM15A to work from VB6 or VB2008?  (Read 7021 times)

kyleg

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 12
anybody get CM15A to work from VB6 or VB2008?
« 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
Logged

hkactive

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 50
Re: anybody get CM15A to work from VB6 or VB2008?
« Reply #1 on: October 12, 2008, 07:57:29 PM »

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.


Code: [Select]
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
Logged

kyleg

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 12
Re: anybody get CM15A to work from VB6 or VB2008?
« Reply #2 on: October 14, 2008, 10:04:15 PM »

thanks...I'll give this one a try as well as well as the other in the previous post
Logged

kyleg

  • Jr. Member
  • **
  • Helpful Post Rating: 0
  • Posts: 12
Re: anybody get CM15A to work from VB6 or VB2008?
« Reply #3 on: October 18, 2008, 07:25:45 PM »

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!!!

Logged
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.