steinie
04-09-2011, 03:29
i need help to convert VB 2005 Import to TB Declare.
If you know Vbasic maybe you can help me out?:o
[VB code]
Imports ActiveHomeScriptLib
Imports System
Module Module1
Dim WithEvents ActiveHomeObj As ActiveHome
<MTAThread()> Sub Main()
'create ActiveHome object
Try
ActiveHomeObj = CreateObject("X10.ActiveHome")
Catch exc As Exception
Console.WriteLine("err num: " & Str(Err.Number) & " '" & exc.ToString & "'")
Finally
End Try
'send a1 on
Try
ActiveHomeObj.SendAction("sendplc", "a1 on")
Catch exc As Exception
Console.WriteLine("err num: " & Str(Err.Number) & " '" & exc.ToString & "'")
Finally
End Try
'wait for events
Dim nRead
While True
System.Threading.Thread.Sleep(0)
nRead = Console.Read()
End While
End Sub
'events from ActiveHome: write out received event
Sub ActiveHome_RecvAction(ByVal bszRecv As Object _
, ByVal vParm1 As Object _
, ByVal vParm2 As Object _
, ByVal vParm3 As Object _
, ByVal vParm4 As Object _
, ByVal vParm5 As Object _
, ByVal vReserved As Object) Handles ActiveHomeObj.RecvAction
Console.WriteLine("RecvAction: " & bszRecv & " " & vParm1 & " " & vParm2 & " " & vParm3 & " " & vParm4 & " " & vParm5)
End Sub
End Module
[/code]
If you know Vbasic maybe you can help me out?:o
[VB code]
Imports ActiveHomeScriptLib
Imports System
Module Module1
Dim WithEvents ActiveHomeObj As ActiveHome
<MTAThread()> Sub Main()
'create ActiveHome object
Try
ActiveHomeObj = CreateObject("X10.ActiveHome")
Catch exc As Exception
Console.WriteLine("err num: " & Str(Err.Number) & " '" & exc.ToString & "'")
Finally
End Try
'send a1 on
Try
ActiveHomeObj.SendAction("sendplc", "a1 on")
Catch exc As Exception
Console.WriteLine("err num: " & Str(Err.Number) & " '" & exc.ToString & "'")
Finally
End Try
'wait for events
Dim nRead
While True
System.Threading.Thread.Sleep(0)
nRead = Console.Read()
End While
End Sub
'events from ActiveHome: write out received event
Sub ActiveHome_RecvAction(ByVal bszRecv As Object _
, ByVal vParm1 As Object _
, ByVal vParm2 As Object _
, ByVal vParm3 As Object _
, ByVal vParm4 As Object _
, ByVal vParm5 As Object _
, ByVal vReserved As Object) Handles ActiveHomeObj.RecvAction
Console.WriteLine("RecvAction: " & bszRecv & " " & vParm1 & " " & vParm2 & " " & vParm3 & " " & vParm4 & " " & vParm5)
End Sub
End Module
[/code]