looking for good visual basic example

Started by russ, January 06, 2006, 07:04:56 PM

Previous topic - Next topic

russ

Has anyone found a good visual basic
example. Any help would be great!

quadrabyte

Russ,

I was able to build a VB.Net application
based on the Interop.ActiveHomeScriptLib that
Visual Studio 2005 created automatically for
me. It took all of about 15 minutes to get
control of my universal on/off units (forget
the model number of those puppies). Very
easy. I can't post the project stuff here but
drop me an email and I'll be happy to zip it
up and send it.

quadrabyte

Hey, Russ, just occurred to me that you don't
know how to 'drop me an email' without my
email address. I think I will get email
notices of any replies to this message, so
try that first.


russ

quadrabyte,
Thanks but not sure I have VB.Net????
What I have is VB6.0

quadrabyte

Russ,

I think everything in this very simple form
is VB6 compatible (or very close). I'll try
simply pouring the text into this reply so
you can copy/paste it into your VS6 tool. My
email address is quadrabyte@gmail.com if you
want to contact me directly for the code.
You'll need to add a reference to the
ActiveHomeScriptLib.dll to get things to link.

Here's the content of the form:
Public Class Form1

Private WithEvents _oActiveHomeController
As New ActiveHomeScriptLib.ActiveHome

Private Sub Button1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Try
If _oActiveHomeController Is
Nothing Then
_oActiveHomeController = New
ActiveHomeScriptLib.ActiveHome
End If

send(TextBox1.Text,
TextBox2.Text, TextBox3.Text, TextBox4.Text)

Catch ex As Exception
MsgBox(ex.Message)
End Try

End Sub

Private Sub
_oActiveHomeController_RecvAction(ByVal
bszAction As Object, ByVal bszParm1 As
Object, ByVal bszParm2 As Object, ByVal
bszParm3 As Object, ByVal bszParm4 As Object,
ByVal bszParm5 As Object, ByVal bszReserved
As Object) Handles
_oActiveHomeController.RecvAction
receive(bszAction, bszParm1,
bszParm2, bszParm3)
End Sub

Private Sub send(ByVal bszAction As
Object, ByVal bszParm1 As Object, ByVal
bszParm2 As Object, ByVal bszParm3 As Object)

_oActiveHomeController.SendAction(bszAction,
bszParm1)
ListBox1.Items.Add("<< " &
bszAction.ToString & " " & bszParm1.ToString
& " " & bszParm2.ToString & " " &
bszParm3.ToString)
End Sub

Private Sub receive(ByVal bszAction As
Object, ByVal bszParm1 As Object, ByVal
bszParm2 As Object, ByVal bszParm3 As Object)
ListBox1.Items.Add(">>     " &
bszAction.ToString & " " & bszParm1.ToString
& " " & bszParm2.ToString & " " &
bszParm3.ToString)
End Sub
End Class

marc

Russ,
Try this example. I've stashed the .vbp,etc
files in a zip file at
http://members.cox.net/marcland/. It's in VB
6, and it's a single form. When the form
loads, it generates 16 on/off buttons (for
unit codes), and a combo-box for selecting
the house code. Nothing fancy: no dimming or
RF, but it should give you a decent example
of using VB to send PLC and to listen the
what the CM15a hears.
Good luck.

russ

Marc,
Great example will provide me with a good
start. Do you know why there are at least
three log entries when a motion detector is
triggered? Is there a way to only get one?
I want to set it up so when the motion is
detected it will trigger something and if
it records it three times it will trigger
it three times, any advise? Thanks for your
help!

marc

Russ,
Very good question. I don't have a clue. As
you've likely seen mentioned in this forum,
x10 has done a poor job of providing
documentation. So why there are three log
entires (or three signals sent per action),
or sometimes only two, and what the -1 or 0
mean, I just don't know.

At least they come very fast. Here's a few
simple thoughts you probably already
considered, but just in case:

1) study the patterns of signals you get
when your motion detector is  triggered.
Even if there are 3 signals, is the one with
the, say, the -1 flag always there, and
always there only once? If so, use that as
your trigger.

2) Always store parameters from the last 3-9
events, and compare the event times. Reject
anything that occured within 2 seconds (or
anytime you choose) of the last set of
signals

3) Use a VB timer to lock out the trigger
for the time period of your choosing.

Anyway, my two cents. Good luck!

marc

Russ,
Ooops, my apologies. I just noticed there is
some info in the ahscript.chm help file in
the folder C:\Program Files\AHSDK\help (at
least that's where it is on my PC). Look in
the section on Using the Scripting
Interface. Apparently the 0,1, -1 is key
data (key up, key down, etc) . What does
that mean for a motion sensor? I dunno...

russ

Marc,
Again thanks for your help all good
suggestions, I will continue to try and
find solution. If you think of any thing
else please let me know.

sport


chrisatwan

I am trying to read a CM19A into PC with VB6. I tried the http://members.cox.net/marcland/ link but said it didn't exist anymore. I know this is a while ago but does anyone have any VB6 expience with a CM19A?

Regards,
Christopher

EL34

I have VB 2008 express example program, not VB6
See my Sig
W10 - CM15A - AHP 3.301 - i Witness - MyHouse online - Smart Macros - SDK using Visual Basic express 2008
My X10 page-> http://www.el34world.com/Misc/home/X10_0.htm

SMF spam blocked by CleanTalk