Please login or register.

Login with username, password and session length
Pages: [1] 2

Author Topic: Rabbits Visual Basic ToyBox  (Read 31219 times)

Rabbit

  • Full Member
  • ***
  • Helpful Post Rating: 6
  • Posts: 33
Rabbits Visual Basic ToyBox
« on: June 05, 2008, 04:10:32 PM »

MOVED FROM THE SDK PROGRAMS FOLDER

A Visual Basic 6 Program for the CM15A

http://gnbi.com/blog/?p=168

I did not write this program. I did, however, figure out the undocumented details left out in the article. I have recreated the object and code and added two error handlers into the script. The assembled .exe file can be downloaded from the site.

The SDK uses a newer version of VB, which I don't have.

Here is the VB6 code:

           
           
           
    Public bszAction As Variant
    Public bszParm1 As Variant
    Public bszParm2 As Variant
    Public bszParm3 As Variant
    Public bszParm4 As Variant
    Public bszParm5 As Variant
    Public strLine As Variant
    Public strTime As String
   
Private Sub ActiveHome1_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)
   
    Text1.Text = bszAction
    Text1.Text = UCase(Text1.Text)
    Text2.Text = bszParm1
    Text2.Text = UCase(Text2.Text)
    Text3.Text = bszParm2
    Text3.Text = UCase(Text3.Text)
    Text4.Text = bszParm3
    Text4.Text = UCase(Text4.Text)
    Text5.Text = bszParm4
    Text5.Text = UCase(Text5.Text)
    Text6.Text = bszParm5
    Text6.Text = UCase(Text6.Text)
   
    strLine = ""
    If (bszAction <> "") Then
        strLine = bszAction
    End If
    strLine = strLine + Chr(9)
    If (bszParm1 <> "") Then
        strLine = strLine + bszParm1
    End If
    strLine = strLine + Chr(9)
    If (bszParm2 <> "") Then
        strLine = strLine + bszParm2
    End If
    strLine = strLine + Chr(9)
    If (bszParm3 <> "") Then
        strLine = strLine + Str(bszParm3)
    End If
    strLine = strLine + Chr(9)
    If (bszParm4 <> "") Then
        strLine = strLine + Str(bszParm4)
    End If
    strLine = strLine + Chr(9)
    If (bszParm5 <> "") Then
        strLine = strLine + Str(bszParm5)
    End If
    If Text1 <> "" And Text2 <> "" And Text3 <> "" And Text4 <> "" And Text5 <> "" Then
    strLine = bszAction + Chr(9) + bszParm1 + Chr(9) + bszParm2 + Chr(9) + Text4.Text
    Text5 = ""
    End If
   
    strTime = CDate(Now)
    Text8.Text = strTime + Space(7) + strLine + vbCrLf + Text8.Text
    Text8.Text = UCase(Text8.Text)
   
End Sub

Private Sub Text9_KeyPress(KeyAscii As Integer)
Char = Chr(KeyAscii)
KeyAscii = Asc(UCase(Char))
End Sub

Private Sub Command1_Click()
On Error Resume Next
If Text9.Text = "" Then
MsgBox "Please Select House Code/Unit", vbQuestion, "X10 CM15A Viewer/Exerciser"
Else: ActiveHome1.SendAction "sendplc", Text9.Text + " on"
End If 'ERROR HANDLER
End Sub

Private Sub Command2_Click()
On Error Resume Next
If Text9.Text = "" Then
MsgBox "Please Select House Code/Unit", vbQuestion, "X10 CM15A Viewer/Exerciser"
Else: ActiveHome1.SendAction "sendplc", Text9.Text + " off"
End If 'ERROR HANDLER
End Sub

Private Sub Command3_Click()
    Text8.Text = ""
End Sub















-----------------------------------------------

If anyone is interested, I can provide details for creating the object (textboxes, labels, command buttons, ect.)

It took a while to figure out how to make this application work since the information provided is incomplete. What I have works just like the .exe program on the website - with two error handlers included.

I have all the files needed to make this VB6 application (.vbp, .vbw, .frm, .frx .ico and .txt files)

I would be happy to provide them to anyone that wishes them.

EDIT: Added Uppercase text only in Textboxes and GUI Image - 6/4/08 - Added Timestamp to event and simplified code

Cheers!
Logged

Rabbit

  • Full Member
  • ***
  • Helpful Post Rating: 6
  • Posts: 33
Re: Rabbits Visual Basic ToyBox
« Reply #1 on: June 05, 2008, 04:14:21 PM »

 A better version

 

Source Code:
     
    Public bszAction As Variant
    Public bszParm1 As Variant
    Public bszParm2 As Variant
    Public bszParm3 As Variant
    Public bszParm4 As Variant
    Public bszParm5 As Variant
    Public strLine As Variant
    Public strTime As String
   
    Private Sub Form_Load()
    Combo1.AddItem "A"
    Combo1.AddItem "B"
    Combo1.AddItem "C"
    Combo1.AddItem "D"
    Combo1.AddItem "E"
    Combo1.AddItem "F"
    Combo1.AddItem "G"
    Combo1.AddItem "H"
    Combo1.AddItem "I"
    Combo1.AddItem "J"
    Combo1.AddItem "K"
    Combo1.AddItem "L"
    Combo1.AddItem "M"
    Combo1.AddItem "N"
    Combo1.AddItem "O"
    Combo1.AddItem "P"
   
    Combo2.AddItem "1"
    Combo2.AddItem "2"
    Combo2.AddItem "3"
    Combo2.AddItem "4"
    Combo2.AddItem "5"
    Combo2.AddItem "6"
    Combo2.AddItem "7"
    Combo2.AddItem "8"
    Combo2.AddItem "9"
    Combo2.AddItem "10"
    Combo2.AddItem "11"
    Combo2.AddItem "12"
    Combo2.AddItem "13"
    Combo2.AddItem "14"
    Combo2.AddItem "15"
    Combo2.AddItem "16"
   
    Combo3.AddItem ""
    Combo3.AddItem "BRIGHT 5"
    Combo3.AddItem "BRIGHT 10"
    Combo3.AddItem "BRIGHT 20"
    Combo3.AddItem "BRIGHT 30"
    Combo3.AddItem "BRIGHT 40"
    Combo3.AddItem "BRIGHT 50"
    Combo3.AddItem "BRIGHT 60"
    Combo3.AddItem "BRIGHT 70"
    Combo3.AddItem "BRIGHT 80"
    Combo3.AddItem "BRIGHT 90"
    Combo3.AddItem "BRIGHT 100"
   
    Combo4.AddItem ""
    Combo4.AddItem "DIM 5"
    Combo4.AddItem "DIM 10"
    Combo4.AddItem "DIM 20"
    Combo4.AddItem "DIM 30"
    Combo4.AddItem "DIM 40"
    Combo4.AddItem "DIM 50"
    Combo4.AddItem "DIM 60"
    Combo4.AddItem "DIM 70"
    Combo4.AddItem "DIM 80"
    Combo4.AddItem "DIM 90"
    Combo4.AddItem "DIM 100"
End Sub
   
Private Sub ActiveHome1_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)
       
    Text1.Text = bszAction
    Text1.Text = UCase(Text1.Text)
    Text2.Text = bszParm1
    Text2.Text = UCase(Text2.Text)
    Text3.Text = bszParm2
    Text3.Text = UCase(Text3.Text)
    Text4.Text = bszParm3
    Text4.Text = UCase(Text4.Text)
    Text5.Text = bszParm4
    Text5.Text = UCase(Text5.Text)
    Text6.Text = bszParm5
    Text6.Text = UCase(Text6.Text)
   
    strLine = ""
    If (bszAction <> "") Then
        strLine = bszAction
    End If
    strLine = strLine + Chr(9)
    If (bszParm1 <> "") Then
        strLine = strLine + bszParm1
    End If
    strLine = strLine + Chr(9)
    If (bszParm2 <> "") Then
        strLine = strLine + bszParm2
    End If
    strLine = strLine + Chr(9)
    If (bszParm3 <> "") Then
        strLine = strLine + Str(bszParm3)
    End If
    strLine = strLine + Chr(9)
    If (bszParm4 <> "") Then
        strLine = strLine + Str(bszParm4)
    End If
    strLine = strLine + Chr(9)
    If (bszParm5 <> "") Then
        strLine = strLine + Str(bszParm5)
    End If
    If Text1 <> "" And Text2 <> "" And Text3 <> "" And Text4 <> "" And Text5 <> "" Then
    strLine = bszAction + Chr(9) + bszParm1 + Chr(9) + bszParm2 + Chr(9) + Text4.Text
    Text5 = ""
    End If
   
    strTime = CDate(Now)
    Text8.Text = strTime + Space(7) + strLine + vbCrLf + Text8.Text
    Text8.Text = UCase(Text8.Text)
End Sub

Private Sub Combo3_KeyPress(KeyAscii As Integer)
Char = Chr(KeyAscii)
KeyAscii = Asc(UCase(Char))
End Sub

Private Sub Combo3_Click()
If Combo3.Text <> "" Then
Command2.Caption = "Bright"
End If
If Combo3.Text = "" Then
Command2.Caption = "Off"
End If
End Sub

Private Sub Combo4_KeyPress(KeyAscii As Integer)
Char = Chr(KeyAscii)
KeyAscii = Asc(UCase(Char))
End Sub

Private Sub Combo4_Click()
If Combo4.Text <> "" Then
Command1.Caption = "Dim"
End If
If Combo4.Text = "" Then
Command1.Caption = "On"
End If
End Sub

Private Sub Text9_KeyPress(KeyAscii As Integer)
Char = Chr(KeyAscii)
KeyAscii = Asc(UCase(Char))
End Sub

Private Sub Command1_Click()

If Combo1.Text = "" Or Combo2.Text = "" Then
MsgBox "Please Select House Code/Unit", vbQuestion, "X10 CM15A Viewer/Exerciser"
Text9.Text = ""
Command1.Caption = "On"
Command2.Caption = "Off"
Combo3.Text = ""
Combo4.Text = ""
Else: Text9.Text = Combo1.Text + Combo2.Text + Space(1) + Combo3.Text + Space(1) + Combo4.Text + " ON"
ActiveHome1.SendAction "sendplc", Text9.Text
Command1.Caption = "On"
Command2.Caption = "Off"
Combo3.Text = ""
Combo4.Text = ""
End If 'ERROR HANDLER
End Sub

Private Sub Command2_Click()

If Combo1.Text = "" Or Combo2.Text = "" Then
MsgBox "Please Select House Code/Unit", vbQuestion, "X10 CM15A Viewer/Exerciser"
Text9.Text = ""
Command1.Caption = "On"
Command2.Caption = "Off"
Combo3.Text = ""
Combo4.Text = ""
Else: Text9.Text = Combo1.Text + Combo2.Text + Space(1) + Combo3.Text + Space(1) + Combo4.Text + " OFF"
ActiveHome1.SendAction "sendplc", Text9.Text
Command1.Caption = "On"
Command2.Caption = "Off"
Combo3.Text = ""
Combo4.Text = ""
End If 'ERROR HANDLER
End Sub

Private Sub Command3_Click()
    Text1.Text = ""
    Text2.Text = ""
    Text3.Text = ""
    Text4.Text = ""
    Text5.Text = ""
    Text6.Text = ""
    Text7.Text = ""
    Text8.Text = ""
    Text9.Text = ""
    Combo1.Text = ""
    Combo2.Text = ""
    Combo3.Text = ""
    Combo4.Text = ""
    Command1.Caption = "On"
    Command2.Caption = "Off"
End Sub

Private Sub Command4_Click()
On Error Resume Next
If Text9.Text = "" Then
MsgBox "Please Enter Command Line Information", vbQuestion, "X10 CM15A Viewer/Exerciser"
Else: ActiveHome1.SendAction "sendplc", Text9.Text
End If
End Sub

Same message as before. If anyone is interested I have all the information available.

Cheers!

Logged

Rabbit

  • Full Member
  • ***
  • Helpful Post Rating: 6
  • Posts: 33
Rabbits X10 Alarm Clock
« Reply #2 on: June 06, 2008, 11:06:38 AM »

I modified an existing VB6 project to use the X10 commands. The alarm clock works until the year 2100. You can select any date and time in the future (till year 2100).

The X10 aspect allows local On Off capability, as well as activating an X10 device using the alarm clock function.

This program I did write!  :D



Source Code: (Not as clean as it could be, but it works!)  ;D

Option Explicit
Const conMinimized = 1

Dim AlarmTime
Dim MyDay As String
Dim MyTime As String
Dim MyDate As String
Dim MyHour As String
Dim MyMinute As String
Dim MySecond As String
Dim MyAMPM As String
Dim MyBeep

'Marquee Banner
Dim strDirection As String
Dim strMessage As String
Dim strTemp As String
Dim Marquee As String


'Synchonize System Clock

Dim sNTP         As String  '32 bit time stamp returned by the server
Dim sngTimeDelay As Single  'time between the acknowledgement of
                            'the connection and the data received.
                            'we compensate by adding half of the round
                            'trip latency

Private Declare Function SetSystemTime Lib "kernel32" _
   (lpSystemTime As SYSTEMTIME) As Long
   
Private Type SYSTEMTIME
  wYear         As Integer
  wMonth        As Integer
  wDayOfWeek    As Integer
  wDay          As Integer
  wHour         As Integer
  wMinute       As Integer
  wSecond       As Integer
  wMilliseconds As Integer
End Type


Private Sub Combo7_Click()
If Combo7.Visible = True Then
Label9.Visible = False
Combo7.Visible = False
Command7.Visible = False
End If
Command8.Visible = True

End Sub



'-------------------------------------------------------------------
Private Sub Form_Load()

    ' Populate the dropdown with various servers.
    '
    With Combo7
        .AddItem ""
        .AddItem "64.236.96.53"
        .AddItem "129.6.15.28"
        .AddItem "129.6.15.29"
        .AddItem "132.163.4.101"
        .AddItem "132.163.4.102"
        .AddItem "132.163.4.103"
        .AddItem "128.138.140.44"
        .AddItem "192.43.244.18"
        .AddItem "131.107.1.10"
        .AddItem "69.25.96.13"
        .AddItem "216.200.93.8"
        .AddItem "208.184.49.9"
        .AddItem "207.126.98.204"
        .AddItem "207.200.81.113"
        .AddItem "68.216.79.113"
        .ListIndex = 0
    End With

AlarmTime = ""
Calendar1.Value = ""
Calendar1.Today
Timer1.Enabled = True
Timer2.Enabled = True
Timer3.Enabled = True
Text1.Visible = False
Text1.Text = ""
Text2.Visible = False
Text2.Text = ""
Text3.Visible = True
Text3.Text = "***** ALARM! *****"
Drive1.Visible = False
Dir1.Visible = False
File1.Visible = False
AlarmClock1.Height = 8190

Dim I As Integer
Dim Ans1 As String
Dim Ans2 As String
   
Ans1 = "0"
Ans2 = I
'-------------------------------------------------------------------
' This Loads Combo1 Hour
For I = 1 To 12 Step 1
Combo1.AddItem I
Next I
'-------------------------------------------------------------------
' This Loads Combo2 & Combo3 Adding 0-9
For I = 0 To 9 Step 1
Ans1 = "0"
Ans2 = I
Combo2.AddItem ":" + Ans1 + Ans2
Combo3.AddItem ":" + Ans1 + Ans2
Next I
'-------------------------------------------------------------------
' This Finishes Combo2 & Combo3 From 10-59
For I = 10 To 59 Step 1
Ans1 = I
Combo2.AddItem ":" + Ans1
Combo3.AddItem ":" + Ans1
Next I
'-------------------------------------------------------------------
' This Loads Combo4 AM/PM
Combo4.AddItem "AM"
Combo4.AddItem "PM"
'-------------------------------------------------------------------
' This Loads Combo5 Beep
For I = 10 To 90 Step 10
Combo5.AddItem I
Next I
For I = 100 To 1000 Step 100
Combo5.AddItem I
Next I
For I = 1000 To 9000 Step 1000
Combo5.AddItem I
Next I

Combo6.Text = "0"

'------------------------------------------------------
'X10 Alarm Clock

'This Loads The House and Unit Codes

    Combo8.AddItem "A"
    Combo8.AddItem "B"
    Combo8.AddItem "C"
    Combo8.AddItem "D"
    Combo8.AddItem "E"
    Combo8.AddItem "F"
    Combo8.AddItem "G"
    Combo8.AddItem "H"
    Combo8.AddItem "I"
    Combo8.AddItem "J"
    Combo8.AddItem "K"
    Combo8.AddItem "L"
    Combo8.AddItem "M"
    Combo8.AddItem "N"
    Combo8.AddItem "O"
    Combo8.AddItem "P"
   
    Combo9.AddItem "1"
    Combo9.AddItem "2"
    Combo9.AddItem "3"
    Combo9.AddItem "4"
    Combo9.AddItem "5"
    Combo9.AddItem "6"
    Combo9.AddItem "7"
    Combo9.AddItem "8"
    Combo9.AddItem "9"
    Combo9.AddItem "10"
    Combo9.AddItem "11"
    Combo9.AddItem "12"
    Combo9.AddItem "13"
    Combo9.AddItem "14"
    Combo9.AddItem "15"
    Combo9.AddItem "16"
  '------------------------------------------------------

End Sub


Private Sub Command1_Click()

Dim Date1 As String
Dim Date2 As String

Dim Ans1 As String
Dim Ans2 As String
Dim Ans3 As String

Dim Ans4 As String
Dim Ans5 As String
Dim Ans6 As String

Dim Result1 As String
Dim Result2 As String
Dim Result3 As String

Dim Result4 As String
Dim Result5 As String
Dim Result6 As String

Dim CalValue1 As String
Dim CalValue2 As String

Date1 = Calendar1.Value
Date2 = Date

'-------------------------------------------------
'First Date Breakdown
Dim iFowardslash As Integer
iFowardslash = 1
iFowardslash = InStr(iFowardslash, Date1, "/")

Ans1 = Left(Date1, iFowardslash - 1)
Result1 = Ans1

Ans2 = Mid(Date1, iFowardslash + 1, 2)
Result2 = Ans2

If InStr(Ans2, "/") Then
Ans2 = Left(Ans2, 1)
Result2 = Ans2
End If

Ans3 = Right(Date1, 2)
Result3 = Ans3

CalValue1 = Result1 + Result2 + Result3
'-------------------------------------------------
'Second Date Breakdown

iFowardslash = 1
iFowardslash = InStr(iFowardslash, Date2, "/")

Ans4 = Left(Date2, iFowardslash - 1)
Result4 = Ans4

Ans5 = Mid(Date2, iFowardslash + 1, 2)
Result5 = Ans5

If InStr(Ans5, "/") Then
Ans5 = Left(Ans5, 1)
Result5 = Ans5
End If

Ans6 = Right(Date2, 2)
Result6 = Ans6
CalValue2 = Result4 + Result5 + Result6
'-------------------------------------------------
Dim Math1 ' As Integer
Dim Math2  As Integer

Math1 = CalValue1
Math2 = CalValue2

If Math1 < Math2 Then
MsgBox "Invalid Date Entered - Please Select Valid Date", vbCritical, "Invalid Date"
Exit Sub
End If

'End Of BreakDown
'-------------------------------------------------

'-------------------------------------------------

If Combo1.Text = "" And Combo2.Text = "" And Combo3.Text = "" And Combo4.Text = "" And Combo5.Text = "" Then
MsgBox "Please Select All Date and Time Elements", vbQuestion, "Rabbits Alarm Clock"
Exit Sub
End If

If Combo1.Text = "" Then
MsgBox "Please Select Hour", vbQuestion, "Rabbits Alarm Clock"
Exit Sub
End If

If Combo2.Text = "" Then
MsgBox "Please Select Minute", vbQuestion, "Rabbits Alarm Clock"
Exit Sub
End If

If Combo3.Text = "" Then
MsgBox "Please Select Second", vbQuestion, "Rabbits Alarm Clock"
Exit Sub
End If

If Combo4.Text = "" Then
MsgBox "Please Select AM or PM", vbQuestion, "Rabbits Alarm Clock"
Exit Sub
End If

If Combo5.Text = "" And Command3.Visible = True And Command4.Visible = True Then
MsgBox "Please Select Number of Beeps", vbQuestion, "Rabbits Alarm Clock"
Exit Sub
End If

Combo6.Text = "0"

MyHour = Combo1.Text
MyMinute = Combo2.Text
MySecond = Combo3.Text
MyAMPM = Combo4.Text
If Combo5.Visible = True Then
MyBeep = Combo5.Text
End If
If Combo5.Visible = False Then
MyBeep = Combo6.Text
End If
MyDate = Calendar1.Value

AlarmTime = MyHour + MyMinute + MySecond + Space(1) + MyAMPM
Label8.Caption = "Alarm Clock is set for: " & MyDate & Space(1) & "At" & Space(1) & AlarmTime

'-------------------------------------------------

If Combo5 >= "10" Then
Command3.Visible = False
Command4.Visible = False
Command5.Visible = True
Command5.Caption = "Stop Alarm"
Command5.ToolTipText = "Stops the Alarm"
End If

Combo1.Visible = False
Combo2.Visible = False
Combo3.Visible = False
Combo4.Visible = False
Combo5.Visible = False
Label1.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
Label5.Visible = False
Label6.Visible = False
Label7.Visible = False
Label8.Visible = True
Frame3.Visible = False
Text3.Visible = False
Calendar1.Visible = False

If Command3.Visible = True And Command4.Visible = True Then
Command1.Visible = False
Command2.Visible = True
End If

If Command3.Visible = False And Command4.Visible = False Then
Command1.Visible = False
Command2.Visible = True
End If

If AlarmTime = "" Then Exit Sub
        AlarmTime = CDate(AlarmTime)
 '-------------------------------------------------

If AlarmTime < Time And Calendar1.Value <= Date Then

AlarmTime = ""

Command1.Visible = True
Command2.Visible = True
Command3.Caption = "Music Alarm"
Command3.ToolTipText = "Plays Single (MP3, WMA, AVI, WAV, ECT.) Files or CD Audio Track(s) at Alarm"
Command4.Visible = True
Command4.Caption = "CD Alarm"
Command4.ToolTipText = "Plays a CD at Alarm"
Command5.Visible = True
Calendar1.Visible = True
Calendar1.Value = ""
Calendar1.Today
Option1.Value = True
Combo1.Clear
Combo2.Clear
Combo3.Clear
Combo4.Clear
Combo5.Clear
Combo6.Clear
Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = True
Text1.Enabled = True
Text1.Visible = False
Text1.Text = ""
Text2.Enabled = True
Text2.Visible = False
Text2.Text = ""
Text3.Enabled = True
Text3.Visible = True
Text3.Text = "***** ALARM! *****"
Drive1.Visible = False
Dir1.Visible = False
File1.Visible = False

If Command5.Caption = "Stop Alarm" Then
Command5.Caption = "Reset"
Command5.ToolTipText = "Resets Alarm Defaults"
End If '------------------------------------------------------------------------------

Dim I As Integer
'Dim Ans1 As String
'Dim Ans2 As String
   
Ans1 = "0"
Ans2 = I
'-------------------------------------------------------------------
' This Loads Combo1 Hour
For I = 1 To 12 Step 1
Combo1.AddItem I
Next I
'-------------------------------------------------------------------
' This Loads Combo2 & Combo3 Adding 0-9
For I = 0 To 9 Step 1
Ans1 = "0"
Ans2 = I
Combo2.AddItem ":" + Ans1 + Ans2
Combo3.AddItem ":" + Ans1 + Ans2
Next I
'-------------------------------------------------------------------
' This Finishes Combo2 & Combo3 From 10-59
For I = 10 To 59 Step 1
Ans1 = I
Combo2.AddItem ":" + Ans1
Combo3.AddItem ":" + Ans1
Next I
'-------------------------------------------------------------------
' This Loads Combo4 AM/PM
Combo4.AddItem "AM"
Combo4.AddItem "PM"
'-------------------------------------------------------------------
' This Loads Combo5 Beep
For I = 10 To 90 Step 10
Combo5.AddItem I
Next I
For I = 100 To 1000 Step 100
Combo5.AddItem I
Next I
For I = 1000 To 9000 Step 1000
Combo5.AddItem I
Next I

Combo6.Text = "0"
'------------------------------------------------------
'X10 Alarm Clock

'This Loads The House and Unit Codes

    Combo8.AddItem "A"
    Combo8.AddItem "B"
    Combo8.AddItem "C"
    Combo8.AddItem "D"
    Combo8.AddItem "E"
    Combo8.AddItem "F"
    Combo8.AddItem "G"
    Combo8.AddItem "H"
    Combo8.AddItem "I"
    Combo8.AddItem "J"
    Combo8.AddItem "K"
    Combo8.AddItem "L"
    Combo8.AddItem "M"
    Combo8.AddItem "N"
    Combo8.AddItem "O"
    Combo8.AddItem "P"
   
    Combo9.AddItem "1"
    Combo9.AddItem "2"
    Combo9.AddItem "3"
    Combo9.AddItem "4"
    Combo9.AddItem "5"
    Combo9.AddItem "6"
    Combo9.AddItem "7"
    Combo9.AddItem "8"
    Combo9.AddItem "9"
    Combo9.AddItem "10"
    Combo9.AddItem "11"
    Combo9.AddItem "12"
    Combo9.AddItem "13"
    Combo9.AddItem "14"
    Combo9.AddItem "15"
    Combo9.AddItem "16"
  '------------------------------------------------------

Combo1.Visible = True
Combo2.Visible = True
Combo3.Visible = True
Combo4.Visible = True
Combo5.Visible = True
Label1.Visible = True
Label2.Visible = True
Label3.Visible = True
Label4.Visible = True
Label5.Visible = True
Label6.Visible = True
Label7.Visible = True
Label8.Visible = False
Frame2.Visible = True
Frame3.Visible = True
Command3.Visible = True
Command4.Visible = True
Check1.Value = 0
Check2.Value = 0
Check1.Visible = True
Check2.Enabled = True
Check2.Visible = True
Check2.Enabled = True

AlarmClock1.Height = 8190


MsgBox "Invalid Time Entered - Please Select Valid Time", vbCritical, "Invalid Time"
Exit Sub
End If

If Command2.Visible = True And Command3.Visible = False And Command4.Visible = False Then
AlarmClock1.Height = 4230
End If

If Combo5.Visible = False And Command3.Visible = True Then
AlarmClock1.Height = 3075
End If

If Combo5.Visible = False And Command4.Visible = True Then
AlarmClock1.Height = 3075
End If

End Sub

Code Continued:
Logged

Rabbit

  • Full Member
  • ***
  • Helpful Post Rating: 6
  • Posts: 33
X10 Alarm Clock
« Reply #3 on: June 06, 2008, 11:10:38 AM »

Private Sub Command2_Click()

If Combo5.Text >= "10" Then
Combo1.Visible = True
Combo2.Visible = True
Combo3.Visible = True
Combo4.Visible = True
Combo5.Visible = True
Label1.Visible = True
Label2.Visible = True
Label3.Visible = True
Label4.Visible = True
Label5.Visible = True
Label6.Visible = True
Label7.Visible = True
Label8.Visible = False
Frame2.Visible = True
Frame3.Visible = True
Check1.Visible = True
Check2.Visible = True
Text1.Visible = False
Text1.Text = ""
Text2.Visible = False
Text2.Text = ""
Text3.Visible = True
Calendar1.Visible = True

End If

Command1.Visible = True
Command2.Visible = False
Command5.Visible = True
Command5.Caption = "Reset"
Command5.ToolTipText = "Resets Alarm Defaults"


If Command2.Caption = "Change Time" And Command3.Visible = False And Command4.Visible = False Then
AlarmClock1.Height = 8190
End If

End Sub





'-------------------------------------------------------
Private Sub Timer1_Timer()
Dim PauseTime, Start, Finish     ' MyTime
Static AlarmSounded As Integer
    
    If Caption <> MyDate & AlarmTime Then
        ' It's now a different second than the one displayed.
        If MyDate & AlarmTime = Date & Time And Not AlarmSounded Then
        
        
'Marquee Script Here
'initialize the operating variables
strDirection = "fowards"

Timer2.Enabled = True


If Check2 = False Then
Text2.Visible = True
Text2.Text = Text3.Text
Text3.Visible = False
End If


Text1.Text = Text3.Text
Text2.Text = Text3.Text

strMessage = UCase(Text3.Text) & Space(50)
strTemp = strMessage

'Start the Marquee

'----------------X10
On Error Resume Next
If Option6.Value = True Then
Text4.Text = Combo8.Text + Combo9.Text + Space(1) + " ON"
End If
If Option7.Value = True Then
Text4.Text = Combo8.Text + Combo9.Text + Space(1) + " OFF"
End If
ActiveHome1.SendAction "sendplc", Text4.Text
'----------------X10

Dim I As Integer
For I = 0 To MyBeep
PauseTime = 0.1
Start = Timer
Do While Timer < Start + PauseTime
DoEvents

Loop
Finish = Timer
If Combo5.Text >= "10" Then
Beep
End If


If Combo5.Text < "10" Then '----------------------------------------------------------------
Check1.Value = 1
Check2.Value = 0
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text1.Visible = False
Text2.Visible = False
Text3.Visible = False
End If

Next I

If Check1.Value = 0 Then
Text3.Visible = False
MsgBox "Alarm At: " & MyDate & Space(3) & AlarmTime
End If

Command5.Caption = "Reset"
Command5.ToolTipText = "Resets Alarm Defaults"

If AlarmClock1.Height = 360 Then
Command1.Visible = False
Command2.Visible = False
Label8.Caption = "Press Exit or Reset"
Exit Sub
End If

If AlarmSounded = False Then
AlarmClock1.Height = 8190
End If

Check1.Value = 0

If Combo5 >= "10" Then
WindowsMediaPlayer.Enabled = False
End If

Check2.Value = 0

AlarmTime = ""

Label8.Visible = False

Text1.Visible = False
Text2.Visible = False
Text3.Visible = False
'------------------------------------------------------------
'------------------------------------------------------------

Dim Pathname As String ''
Dim Filename As String ''
Dim SongList
Pathname = Dir1.Path ''
Filename = File1.Filename ''


If Command3.Visible = True And Command4.Visible = False Then
WindowsMediaPlayer.openPlayer Pathname & "\" & Filename '' 'Works External Player
Check1.Value = 0
End If

If Command3.Visible = False And Command4.Visible = True Then
WindowsMediaPlayer.Enabled = False
End If

If Command3.Visible = False And Command4.Visible = True Then
On Error Resume Next
Call Shell("C:\WINDOWS\system32\cdplayer.exe")
Call Shell("C:\WINDOWS\cdplayer.exe")
Call Shell("C:\cdplayer.exe")
Call Shell("C:\WINNT\system32\cdplayer.exe")
End If



If Combo5 >= "10" Then
WindowsMediaPlayer.Enabled = False
Check1.Value = 0
Check2.Visible = True
Check2.Enabled = True
Command3.Visible = True
Command5.Visible = True
End If




            '--- Place Other Actions Here
            
'------------------------------------------------------------
'------------------------------------------------------------
            AlarmSounded = True
        ElseIf Time < AlarmTime Then
            AlarmSounded = False
        End If
        If WindowState = conMinimized Then
            '---
            '---
        Else
            '---
            '---
        If AlarmSounded = True Then
        Label8.Caption = ""
        
Combo1.Visible = True
Combo2.Visible = True
Combo3.Visible = True
Combo4.Visible = True
Combo5.Visible = True
Combo7.Visible = False
Label1.Visible = True
Label2.Visible = True
Label3.Visible = True
Label4.Visible = True
Label5.Visible = True
Label6.Visible = True
Label7.Visible = True
Label8.Visible = False
Label9.Visible = False
Frame2.Visible = True
Frame3.Visible = True
Check1.Visible = True
Check1.Value = 0
Check2.Enabled = True
Check2.Visible = True
Text1.Visible = False
Text1.Enabled = True
Text1.Text = ""
Text2.Visible = False
Text2.Enabled = True
Text2.Text = ""
Text3.Visible = True
Text3.Enabled = True
Text3.Text = "***** ALARM! *****"
Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = True
Command1.Visible = True
Command2.Visible = False
Command3.Visible = True
Command3.Caption = "Music Alarm"
Command3.ToolTipText = "Plays Single (MP3, WMA, AVI, WAV, ECT.) Files or CD Audio Track(s) at Alarm"
Command4.Visible = True
Command4.Caption = "CD Alarm"
Command4.ToolTipText = "Plays a CD at Alarm"
Command7.Visible = True
Command8.Visible = False
Calendar1.Visible = True

Combo7.Clear

' Populate the dropdown with various servers.
    '
    With Combo7
        .AddItem ""
        .AddItem "64.236.96.53"
        .AddItem "129.6.15.28"
        .AddItem "129.6.15.29"
        .AddItem "132.163.4.101"
        .AddItem "132.163.4.102"
        .AddItem "132.163.4.103"
        .AddItem "128.138.140.44"
        .AddItem "192.43.244.18"
        .AddItem "131.107.1.10"
        .AddItem "69.25.96.13"
        .AddItem "216.200.93.8"
        .AddItem "208.184.49.9"
        .AddItem "207.126.98.204"
        .AddItem "207.200.81.113"
        .AddItem "68.216.79.113"
        .ListIndex = 0
    End With

AlarmTime = ""

Combo1.Clear
Combo2.Clear
Combo3.Clear
Combo4.Clear
Combo5.Clear
Combo6.Clear
Combo8.Clear
Combo9.Clear
Option6.Value = False
Option7.Value = False

Dim Ans1 As String
Dim Ans2 As String
    
Ans1 = "0"
Ans2 = I
'-------------------------------------------------------------------
' This Loads Combo1 Hour
For I = 1 To 12 Step 1
Combo1.AddItem I
Next I
'-------------------------------------------------------------------
' This Loads Combo2 & Combo3 Adding 0-9
For I = 0 To 9 Step 1
Ans1 = "0"
Ans2 = I
Combo2.AddItem ":" + Ans1 + Ans2
Combo3.AddItem ":" + Ans1 + Ans2
Next I
'-------------------------------------------------------------------
' This Finishes Combo2 & Combo3 From 10-59
For I = 10 To 59 Step 1
Ans1 = I
Combo2.AddItem ":" + Ans1
Combo3.AddItem ":" + Ans1
Next I
'-------------------------------------------------------------------
' This Loads Combo4 AM/PM
Combo4.AddItem "AM"
Combo4.AddItem "PM"
'-------------------------------------------------------------------
' This Loads Combo5 Beep
For I = 10 To 90 Step 10
Combo5.AddItem I
Next I
For I = 100 To 1000 Step 100
Combo5.AddItem I
Next I
For I = 1000 To 9000 Step 1000
Combo5.AddItem I
Next I

'Combo6.Text = "0"
'------------------------------------------------------
'X10 Alarm Clock

'This Loads The House and Unit Codes

    Combo8.AddItem "A"
    Combo8.AddItem "B"
    Combo8.AddItem "C"
    Combo8.AddItem "D"
    Combo8.AddItem "E"
    Combo8.AddItem "F"
    Combo8.AddItem "G"
    Combo8.AddItem "H"
    Combo8.AddItem "I"
    Combo8.AddItem "J"
    Combo8.AddItem "K"
    Combo8.AddItem "L"
    Combo8.AddItem "M"
    Combo8.AddItem "N"
    Combo8.AddItem "O"
    Combo8.AddItem "P"
    
    Combo9.AddItem "1"
    Combo9.AddItem "2"
    Combo9.AddItem "3"
    Combo9.AddItem "4"
    Combo9.AddItem "5"
    Combo9.AddItem "6"
    Combo9.AddItem "7"
    Combo9.AddItem "8"
    Combo9.AddItem "9"
    Combo9.AddItem "10"
    Combo9.AddItem "11"
    Combo9.AddItem "12"
    Combo9.AddItem "13"
    Combo9.AddItem "14"
    Combo9.AddItem "15"
    Combo9.AddItem "16"
  '------------------------------------------------------
        End If
      End If
    End If
End Sub



'------------------------------------------------------------
Private Sub Command3_Click()

AlarmTime = ""

Combo5.Clear
Combo6.Text = "0"

If Combo6.Text = "0" Then
Combo5.Visible = False
Label5.Visible = False
Check1.Value = 1
Check1.Visible = False
Check2.Value = 0
Check2.Visible = False
Frame2.Visible = False
End If

Command1.Visible = False
Command2.Visible = False
Command3.Visible = True
Command4.Visible = False
Command5.Caption = "Reset" '--------------------------------------------------------
Command5.ToolTipText = "Resets Alarm Defaults" '--------------------------------------------
Command5.Visible = True
Check1.Value = 1
Check1.Enabled = True
Check1.Visible = False
Check2.Enabled = False
Check2.Visible = False
Frame2.Visible = False
Frame3.Visible = False
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text1.Visible = False
Text2.Visible = False
Text3.Visible = False
Label1.Visible = False
Label2.Visible = False
Label3.Visible = False
Label4.Visible = False
Label5.Visible = False
Label6.Visible = False
Label7.Visible = False
Label8.Visible = False
Combo1.Visible = False
Combo2.Visible = False
Combo3.Visible = False
Combo4.Visible = False
Combo5.Visible = False
Calendar1.Visible = False
Drive1.Visible = True
Dir1.Visible = True
File1.Visible = True

If Command3.Caption = "Change" Then
AlarmClock1.Height = 8190
End If

End Sub

Private Sub Command4_Click()

AlarmTime = ""

Combo5.Clear
Combo6.Text = "0"

If Combo6.Text = "0" Then
Combo5.Visible = False
Label5.Visible = False
Check1.Value = 1
Check1.Visible = False
Check2.Value = 0
Check2.Visible = False
Frame2.Visible = False
End If

Command1.Visible = True
Command2.Visible = True
Command3.Visible = False
Command4.Visible = True
Command4.Caption = "Change" '--------------------------------------------------------
Command4.ToolTipText = "Change CD Alarm Time" '--------------------------------------------
Command5.Visible = True
Command5.Caption = "Reset"
Command5.ToolTipText = "Resets Alarm Defaults"
Check1.Value = 1
Check1.Enabled = True
Check1.Visible = False
Check2.Enabled = False
Check2.Visible = False
Frame2.Visible = False
Frame3.Visible = True
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text1.Visible = False
Text2.Visible = False
Text3.Visible = False
Combo1.Visible = True
Combo2.Visible = True
Combo3.Visible = True
Combo4.Visible = True
Combo5.Visible = False
Label1.Visible = True
Label2.Visible = True
Label3.Visible = True
Label4.Visible = True
Label5.Visible = False
Label6.Visible = True
Label7.Visible = False
Label8.Visible = False
Calendar1.Visible = True

If Command4.Caption = "Change" Then
AlarmClock1.Height = 8190
End If

End Sub

Private Sub Command5_Click()

AlarmTime = ""

Command1.Visible = True
Command2.Visible = True
Command3.Caption = "Music Alarm"
Command3.ToolTipText = "Plays Single (MP3, WMA, AVI, WAV, ECT.) Files or CD Audio Track(s) at Alarm"
Command4.Visible = True
Command4.Caption = "CD Alarm"
Command4.ToolTipText = "Plays a CD at Alarm"
Command5.Visible = True
Command7.Visible = True
Command8.Visible = False
Calendar1.Visible = True
Calendar1.Value = ""
Calendar1.Today
Option1.Value = True
Option6.Value = False
Option7.Value = False
Combo1.Clear
Combo2.Clear
Combo3.Clear
Combo4.Clear
Combo5.Clear
Combo6.Clear
Combo7.Clear
Combo8.Clear
Combo9.Clear
Combo7.Visible = False
Timer1.Enabled = True
Timer2.Enabled = False
Timer3.Enabled = True
Text1.Enabled = True
Text1.Visible = False
Text1.Text = ""
Text2.Enabled = True
Text2.Visible = False
Text2.Text = ""
Text3.Enabled = True
Text3.Visible = True
Text3.Text = "***** ALARM! *****"
Label9.Visible = False
Drive1.Visible = False
Dir1.Visible = False
File1.Visible = False

« Last Edit: June 06, 2008, 12:26:43 PM by Rabbit »
Logged

Rabbit

  • Full Member
  • ***
  • Helpful Post Rating: 6
  • Posts: 33
Re: Rabbits Visual Basic ToyBox
« Reply #4 on: June 06, 2008, 11:11:01 AM »

If Command5.Caption = "Stop Alarm" Then
Command5.Caption = "Reset"
Command5.ToolTipText = "Resets Alarm Defaults"
End If '------------------------------------------------------------------------------

Dim I As Integer
Dim Ans1 As String
Dim Ans2 As String
   
Ans1 = "0"
Ans2 = I
'-------------------------------------------------------------------
' This Loads Combo1 Hour
For I = 1 To 12 Step 1
Combo1.AddItem I
Next I
'-------------------------------------------------------------------
' This Loads Combo2 & Combo3 Adding 0-9
For I = 0 To 9 Step 1
Ans1 = "0"
Ans2 = I
Combo2.AddItem ":" + Ans1 + Ans2
Combo3.AddItem ":" + Ans1 + Ans2
Next I
'-------------------------------------------------------------------
' This Finishes Combo2 & Combo3 From 10-59
For I = 10 To 59 Step 1
Ans1 = I
Combo2.AddItem ":" + Ans1
Combo3.AddItem ":" + Ans1
Next I
'-------------------------------------------------------------------
' This Loads Combo4 AM/PM
Combo4.AddItem "AM"
Combo4.AddItem "PM"
'-------------------------------------------------------------------
' This Loads Combo5 Beep
For I = 10 To 90 Step 10
Combo5.AddItem I
Next I
For I = 100 To 1000 Step 100
Combo5.AddItem I
Next I
For I = 1000 To 9000 Step 1000
Combo5.AddItem I
Next I

Combo6.Text = "0"
'------------------------------------------------------
'X10 Alarm Clock

'This Loads The House and Unit Codes

    Combo8.AddItem "A"
    Combo8.AddItem "B"
    Combo8.AddItem "C"
    Combo8.AddItem "D"
    Combo8.AddItem "E"
    Combo8.AddItem "F"
    Combo8.AddItem "G"
    Combo8.AddItem "H"
    Combo8.AddItem "I"
    Combo8.AddItem "J"
    Combo8.AddItem "K"
    Combo8.AddItem "L"
    Combo8.AddItem "M"
    Combo8.AddItem "N"
    Combo8.AddItem "O"
    Combo8.AddItem "P"
   
    Combo9.AddItem "1"
    Combo9.AddItem "2"
    Combo9.AddItem "3"
    Combo9.AddItem "4"
    Combo9.AddItem "5"
    Combo9.AddItem "6"
    Combo9.AddItem "7"
    Combo9.AddItem "8"
    Combo9.AddItem "9"
    Combo9.AddItem "10"
    Combo9.AddItem "11"
    Combo9.AddItem "12"
    Combo9.AddItem "13"
    Combo9.AddItem "14"
    Combo9.AddItem "15"
    Combo9.AddItem "16"
  '------------------------------------------------------
Combo1.Visible = True
Combo2.Visible = True
Combo3.Visible = True
Combo4.Visible = True
Combo5.Visible = True
Label1.Visible = True
Label2.Visible = True
Label3.Visible = True
Label4.Visible = True
Label5.Visible = True
Label6.Visible = True
Label7.Visible = True
Label8.Visible = False
Frame2.Visible = True
Frame3.Visible = True
Command3.Visible = True
Command4.Visible = True
Check1.Value = 0
Check2.Value = 0
Check1.Visible = True
Check2.Enabled = True
Check2.Visible = True
Check2.Enabled = True

AlarmClock1.Height = 8190

' Populate the dropdown with various servers.
    '
    With Combo7
        .AddItem ""
        .AddItem "64.236.96.53"
        .AddItem "129.6.15.28"
        .AddItem "129.6.15.29"
        .AddItem "132.163.4.101"
        .AddItem "132.163.4.102"
        .AddItem "132.163.4.103"
        .AddItem "128.138.140.44"
        .AddItem "192.43.244.18"
        .AddItem "131.107.1.10"
        .AddItem "69.25.96.13"
        .AddItem "216.200.93.8"
        .AddItem "208.184.49.9"
        .AddItem "207.126.98.204"
        .AddItem "207.200.81.113"
        .AddItem "68.216.79.113"
        .ListIndex = 0
    End With

End Sub



Private Sub Command6_Click()
End
End Sub

'-------------------------------------------------------
'-------------------------------------------------------
Private Sub Command7_Click()

Command7.Caption = "Select IP Address"

If Command7.Caption = "Select IP Address" Then
Command8.Visible = True
Command8.Caption = "Synchronize"
Label9.Visible = True
Combo7.Visible = True
End If

End Sub
'------------------------------------------------------
Private Sub Command8_Click()

If Combo7.Text = "" Then
MsgBox "Please Select An IP Address", vbQuestion, "Rabbits Alarm Clock"
Command8.Visible = False
Command7.Visible = True
End If

If Command8.Caption = "Synchronize" Then
With Winsock1
        .Close
        sNTP = Empty
        '
        ' Set the server's name.
        '
        .RemoteHost = Combo7.Text
        '
        ' Set the port.
        '
        .RemotePort = 37  'NTP server's port
        .Connect
    End With
    End If


End Sub

'------------------------------------------------------

Private Sub Drive1_Change()
On Error Resume Next
Dir1.Path = Drive1.Drive
File1.Path = Dir1.Path
End Sub

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub File1_Click()
Dim SelectedFile As String
Dim FilePath As String
SelectedFile = File1.Filename
FilePath = File1.Path + "\" + SelectedFile

Command1.Visible = True
Command2.Visible = True
Command3.Visible = True
Command3.Caption = "Change"
Command3.ToolTipText = "Change Music Alarm Settings"
Command4.Visible = False
Command5.Visible = True
Check1.Value = 1
Check1.Enabled = True
Check1.Visible = False
Check2.Value = 0
Check2.Enabled = False
Check2.Visible = False
Frame2.Visible = False
Frame3.Visible = True
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text1.Visible = False
Text2.Visible = False
Text3.Visible = False
Label1.Visible = True
Label2.Visible = True
Label3.Visible = True
Label4.Visible = True
Label5.Visible = False
Label6.Visible = True
Label7.Visible = False
Combo1.Visible = True
Combo2.Visible = True
Combo3.Visible = True
Combo4.Visible = True
Combo5.Visible = False
Combo6.Clear
Calendar1.Visible = True
Drive1.Visible = False
Dir1.Visible = False
File1.Visible = False

End Sub

'-------------------------------------------------------
Private Sub Form_Resize()
    If WindowState = conMinimized Then   'If form is minimized, dislay the time in a caption.
        'SetCaptionTime
    Else
        Caption = "Rabbits Alarm Clock"
    End If
End Sub

'-------------------------------------------------------
Private Sub ShowTime()

If Option1.Value = True Then
  MyDate = Date
Label10.Caption = Format(MyDate, "dddd  mmmm d, yyyy") & Space(3) & Time
End If
If Option2.Value = True Then
  MyDate = Date
Label10.Caption = Format(MyDate, "dddd")
End If
If Option3.Value = True Then
  MyDate = Date
Label10.Caption = Format(MyDate, "mmmm d, yyyy")
End If
If Option4.Value = True Then
Label10.Caption = Time
End If
If Option5.Value = True Then
  MyDate = Date
Label10.Caption = Format(MyDate, "mmmm d, yyyy") & Space(3) & Time
End If

End Sub

Private Sub Option1_Click()
ShowTime
End Sub

Private Sub Option2_Click()
ShowTime
End Sub

Private Sub Option3_Click()
ShowTime
End Sub

Private Sub Option4_Click()
ShowTime
End Sub

Private Sub Option5_Click()
ShowTime
End Sub

Private Sub Timer3_Timer()
ShowTime
End Sub

'------------------------------------------------------------
Private Sub Timer2_Timer()
If (strDirection = "fowards") Then
strTemp = Right(strTemp, Len(strTemp) - 1) & Mid(strTemp, 1, 1)


Text1.Visible = True
Text1.Text = strTemp
'Else'---------------------------------------------------------------------------------
'strTemp = Right(strTemp, 1) & Mid(strTemp, 1, Len(strTemp) - 1)
End If
End Sub

Private Sub WinSock1_DataArrival(ByVal bytesTotal As Long)
Dim sData As String

    Call Winsock1.GetData(sData, vbString)
    sNTP = sNTP & sData
End Sub
Private Sub WinSock1_Connect()
    sngTimeDelay = Timer
End Sub
Private Sub WinSock1_Close()
On Error Resume Next

Do Until Winsock1.State = sckClosed
    Winsock1.Close
    DoEvents
Loop

sngTimeDelay = ((Timer - sngTimeDelay) / 2)
Call SyncClock(sNTP)
End Sub
Private Sub SyncClock(sTemp As String)
Dim dblNTPTime      As Double
Dim UTCDATE         As Date
Dim LngTimeFrom1990 As Long
Dim ST              As SYSTEMTIME
     
sTemp = Trim$(sTemp)
If Len(sTemp) <> 4 Then
    Call MsgBox("NTP Server returned an invalid response.", _
                vbCritical, "Invalid Response")
    Exit Sub
End If

dblNTPTime = Asc(Left$(sTemp, 1)) * 256 ^ 3 + Asc(Mid$(sTemp, 2, 1)) * 256 ^ 2 + Asc(Mid$(sTemp, 3, 1)) * 256 ^ 1 + Asc(Right$(sTemp, 1))
     
LngTimeFrom1990 = dblNTPTime - 2840140800#

UTCDATE = DateAdd("s", CDbl(LngTimeFrom1990 + CLng(sngTimeDelay)), #1/1/1990#)

With ST
    .wYear = Year(UTCDATE)
    .wMonth = Month(UTCDATE)
    .wDay = Day(UTCDATE)
    .wHour = Hour(UTCDATE)
    .wMinute = Minute(UTCDATE)
    .wSecond = Second(UTCDATE)
End With

Call SetSystemTime(ST)
Call MsgBox("Clock Synchronized Successfully.", vbInformation, "Rabbits Alarm Clock")

Command8.Visible = False
Command7.Visible = True
Combo7.Clear

' Populate the dropdown with various servers.
    '
    With Combo7
        .AddItem ""
        .AddItem "64.236.96.53"
        .AddItem "129.6.15.28"
        .AddItem "129.6.15.29"
        .AddItem "132.163.4.101"
        .AddItem "132.163.4.102"
        .AddItem "132.163.4.103"
        .AddItem "128.138.140.44"
        .AddItem "192.43.244.18"
        .AddItem "131.107.1.10"
        .AddItem "69.25.96.13"
        .AddItem "216.200.93.8"
        .AddItem "208.184.49.9"
        .AddItem "207.126.98.204"
        .AddItem "207.200.81.113"
        .AddItem "68.216.79.113"
        .ListIndex = 0
    End With

End Sub
'-------------------------------------------------------------------
' X10 Alarm Elements

Private Sub Command9_Click()
On Error Resume Next
If Combo8.Text = "" Or Combo9.Text = "" Then
MsgBox "Please Select House Code / Unit Code", vbQuestion, "Rabbits Alarm Clock"
End If
If Option6.Value = False And Option7.Value = False Then
MsgBox "Please Select An On / Off Option", vbQuestion, "Rabbits Alarm Clock"
End If
If Option6.Value = True Then
Text4.Text = Combo8.Text + Combo9.Text + Space(1) + " ON"
End If
If Option7.Value = True Then
Text4.Text = Combo8.Text + Combo9.Text + Space(1) + " OFF"
End If
ActiveHome1.SendAction "sendplc", Text4.Text
End Sub



Cheers!
Logged

Brian H

  • Community Organizer
  • Hero Member
  • ***
  • Helpful Post Rating: 305
  • Posts: 13295
Re: Rabbits Visual Basic ToyBox
« Reply #5 on: June 06, 2008, 11:19:46 AM »

Thank you for all the work in getting this and sharing with the X10 users. #:)
Logged

Rabbit

  • Full Member
  • ***
  • Helpful Post Rating: 6
  • Posts: 33
Re: Rabbits Visual Basic ToyBox
« Reply #6 on: June 06, 2008, 11:37:38 AM »

Thx, Brian. I'm hoping someone will request the source files for one of these programs (all the VB files).  The .exe file is also available. (They can be sent via email as a .txt file and then change the extension back to .exe when received) They run quite fast compared to AHP! (Don't know why...)

After I built the last two programs, I don't fire up AHP anymore for the local computer control of my X10 devices (I've memorized most of my X10 addresses). The programs load faster than AHP, run macros, and they don't crash! LOL!

Cheers!
Logged

Rabbit

  • Full Member
  • ***
  • Helpful Post Rating: 6
  • Posts: 33
Re: Rabbits Visual Basic ToyBox
« Reply #7 on: June 09, 2008, 09:01:31 AM »

My latest program. It controls all 256 X10 addresses. The code is 3Megs, so I can't post it easily. The Main view  (1st image) is the normal state when executed.

The House codes are selected using the lower left Combo Box. There are 16 of these forms - one for each House Code.



This view shows the Activity Monitor.



Here is some of the code:

Public bszAction As Variant
    Public bszParm1 As Variant
    Public bszParm2 As Variant
    Public bszParm3 As Variant
    Public bszParm4 As Variant
    Public bszParm5 As Variant
    Public strLine As Variant
    Public strTime As String

Private Sub ActiveHome1_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)
    strTime = CDate(Now)
    strLine = bszAction + Chr(9) + bszParm1 + Chr(9) + bszParm2 + Chr(9)
    Text1000.Text = strTime + Space(7) + strLine + vbCrLf + Text1000.Text
    Text1000.Text = UCase(Text1000.Text)
End Sub

Private Sub Form_Load()

Combo10000.AddItem "A"
Combo10000.AddItem "B"
Combo10000.AddItem "C"
Combo10000.AddItem "D"
Combo10000.AddItem "E"
Combo10000.AddItem "F"
Combo10000.AddItem "G"
Combo10000.AddItem "H"
Combo10000.AddItem "I"
Combo10000.AddItem "J"
Combo10000.AddItem "K"
Combo10000.AddItem "L"
Combo10000.AddItem "M"
Combo10000.AddItem "N"
Combo10000.AddItem "O"
Combo10000.AddItem "P"
   
Combo20000.AddItem "1"
Combo20000.AddItem "2"
Combo20000.AddItem "3"
Combo20000.AddItem "4"
Combo20000.AddItem "5"
Combo20000.AddItem "6"
Combo20000.AddItem "7"
Combo20000.AddItem "8"
Combo20000.AddItem "9"
Combo20000.AddItem "10"
Combo20000.AddItem "11"
Combo20000.AddItem "12"
Combo20000.AddItem "13"
Combo20000.AddItem "14"
Combo20000.AddItem "15"
Combo20000.AddItem "16"

Combo30000.AddItem "A"
Combo30000.AddItem "B"
Combo30000.AddItem "C"
Combo30000.AddItem "D"
Combo30000.AddItem "E"
Combo30000.AddItem "F"
Combo30000.AddItem "G"
Combo30000.AddItem "H"
Combo30000.AddItem "I"
Combo30000.AddItem "J"
Combo30000.AddItem "K"
Combo30000.AddItem "L"
Combo30000.AddItem "M"
Combo30000.AddItem "N"
Combo30000.AddItem "O"
Combo30000.AddItem "P"

Combo40000.AddItem "A ON"
Combo40000.AddItem "A OFF"
Combo40000.AddItem "A DIM"
Combo40000.AddItem "A BRIGHT"
Combo40000.AddItem "A ALLLIGHTSON"
Combo40000.AddItem "A ALLUNITSOFF"
Combo40000.AddItem "A STATUSON"
Combo40000.AddItem "A STATUSOFF"
Combo40000.AddItem "A STATUSREQUEST"
Combo40000.AddItem "A PRESETDIM1"
Combo40000.AddItem "A PRESETDIM2"
Combo40000.AddItem "A EXTCODE"
Combo40000.AddItem "A EXTENDEDDATATRANSFER"
Combo40000.AddItem "A HAILREQUEST"
Combo40000.AddItem "A HAILACKNOWLEDGE"

Text1000.Text = ""

End Sub

Private Sub Command40000_Click()
If Combo30000.Text = "A" Then
X10ControllerA.Visible = True
X10ControllerB.Visible = False
X10ControllerC.Visible = False
X10ControllerD.Visible = False
X10ControllerE.Visible = False
X10ControllerF.Visible = False
X10ControllerG.Visible = False
X10ControllerH.Visible = False
X10ControllerI.Visible = False
X10ControllerJ.Visible = False
X10ControllerK.Visible = False
X10ControllerL.Visible = False
X10ControllerM.Visible = False
X10ControllerN.Visible = False
X10ControllerO.Visible = False
X10ControllerP.Visible = False
End If

If Combo30000.Text = "B" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = True
X10ControllerC.Visible = False
X10ControllerD.Visible = False
X10ControllerE.Visible = False
X10ControllerF.Visible = False
X10ControllerG.Visible = False
X10ControllerH.Visible = False
X10ControllerI.Visible = False
X10ControllerJ.Visible = False
X10ControllerK.Visible = False
X10ControllerL.Visible = False
X10ControllerM.Visible = False
X10ControllerN.Visible = False
X10ControllerO.Visible = False
X10ControllerP.Visible = False
End If

If Combo30000.Text = "C" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = False
X10ControllerC.Visible = True
X10ControllerD.Visible = False
X10ControllerE.Visible = False
X10ControllerF.Visible = False
X10ControllerG.Visible = False
X10ControllerH.Visible = False
X10ControllerI.Visible = False
X10ControllerJ.Visible = False
X10ControllerK.Visible = False
X10ControllerL.Visible = False
X10ControllerM.Visible = False
X10ControllerN.Visible = False
X10ControllerO.Visible = False
X10ControllerP.Visible = False
End If

If Combo30000.Text = "D" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = False
X10ControllerC.Visible = False
X10ControllerD.Visible = True
X10ControllerE.Visible = False
X10ControllerF.Visible = False
X10ControllerG.Visible = False
X10ControllerH.Visible = False
X10ControllerI.Visible = False
X10ControllerJ.Visible = False
X10ControllerK.Visible = False
X10ControllerL.Visible = False
X10ControllerM.Visible = False
X10ControllerN.Visible = False
X10ControllerO.Visible = False
X10ControllerP.Visible = False
End If

If Combo30000.Text = "E" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = False
X10ControllerC.Visible = False
X10ControllerD.Visible = False
X10ControllerE.Visible = True
X10ControllerF.Visible = False
X10ControllerG.Visible = False
X10ControllerH.Visible = False
X10ControllerI.Visible = False
X10ControllerJ.Visible = False
X10ControllerK.Visible = False
X10ControllerL.Visible = False
X10ControllerM.Visible = False
X10ControllerN.Visible = False
X10ControllerO.Visible = False
X10ControllerP.Visible = False
End If

If Combo30000.Text = "F" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = False
X10ControllerC.Visible = False
X10ControllerD.Visible = False
X10ControllerE.Visible = False
X10ControllerF.Visible = True
X10ControllerG.Visible = False
X10ControllerH.Visible = False
X10ControllerI.Visible = False
X10ControllerJ.Visible = False
X10ControllerK.Visible = False
X10ControllerL.Visible = False
X10ControllerM.Visible = False
X10ControllerN.Visible = False
X10ControllerO.Visible = False
X10ControllerP.Visible = False
End If

If Combo30000.Text = "G" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = False
X10ControllerC.Visible = False
X10ControllerD.Visible = False
X10ControllerE.Visible = False
X10ControllerF.Visible = False
X10ControllerG.Visible = True
X10ControllerH.Visible = False
X10ControllerI.Visible = False
X10ControllerJ.Visible = False
X10ControllerK.Visible = False
X10ControllerL.Visible = False
X10ControllerM.Visible = False
X10ControllerN.Visible = False
X10ControllerO.Visible = False
X10ControllerP.Visible = False
End If

If Combo30000.Text = "H" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = False
X10ControllerC.Visible = False
X10ControllerD.Visible = False
X10ControllerE.Visible = False
X10ControllerF.Visible = False
X10ControllerG.Visible = False
X10ControllerH.Visible = True
X10ControllerI.Visible = False
X10ControllerJ.Visible = False
X10ControllerK.Visible = False
X10ControllerL.Visible = False
X10ControllerM.Visible = False
X10ControllerN.Visible = False
X10ControllerO.Visible = False
X10ControllerP.Visible = False
End If

If Combo30000.Text = "I" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = False
X10ControllerC.Visible = False
X10ControllerD.Visible = False
X10ControllerE.Visible = False
X10ControllerF.Visible = False
X10ControllerG.Visible = False
X10ControllerH.Visible = False
X10ControllerI.Visible = True
X10ControllerJ.Visible = False
X10ControllerK.Visible = False
X10ControllerL.Visible = False
X10ControllerM.Visible = False
X10ControllerN.Visible = False
X10ControllerO.Visible = False
X10ControllerP.Visible = False
End If

If Combo30000.Text = "J" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = False
X10ControllerC.Visible = False
X10ControllerD.Visible = False
X10ControllerE.Visible = False
X10ControllerF.Visible = False
X10ControllerG.Visible = False
X10ControllerH.Visible = False
X10ControllerI.Visible = False
X10ControllerJ.Visible = True
X10ControllerK.Visible = False
X10ControllerL.Visible = False
X10ControllerM.Visible = False
X10ControllerN.Visible = False
X10ControllerO.Visible = False
X10ControllerP.Visible = False
End If

If Combo30000.Text = "K" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = False
X10ControllerC.Visible = False
X10ControllerD.Visible = False
X10ControllerE.Visible = False
X10ControllerF.Visible = False
X10ControllerG.Visible = False
X10ControllerH.Visible = False
X10ControllerI.Visible = False
X10ControllerJ.Visible = False
X10ControllerK.Visible = True
X10ControllerL.Visible = False
X10ControllerM.Visible = False
X10ControllerN.Visible = False
X10ControllerO.Visible = False
X10ControllerP.Visible = False
End If

If Combo30000.Text = "L" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = False
X10ControllerC.Visible = False
X10ControllerD.Visible = False
X10ControllerE.Visible = False
X10ControllerF.Visible = False
X10ControllerG.Visible = False
X10ControllerH.Visible = False
X10ControllerI.Visible = False
X10ControllerJ.Visible = False
X10ControllerK.Visible = False
X10ControllerL.Visible = True
X10ControllerM.Visible = False
X10ControllerN.Visible = False
X10ControllerO.Visible = False
X10ControllerP.Visible = False
End If

If Combo30000.Text = "M" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = False
X10ControllerC.Visible = False
X10ControllerD.Visible = False
X10ControllerE.Visible = False
X10ControllerF.Visible = False
X10ControllerG.Visible = False
X10ControllerH.Visible = False
X10ControllerI.Visible = False
X10ControllerJ.Visible = False
X10ControllerK.Visible = False
X10ControllerL.Visible = False
X10ControllerM.Visible = True
X10ControllerN.Visible = False
X10ControllerO.Visible = False
X10ControllerP.Visible = False
End If

If Combo30000.Text = "N" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = False
X10ControllerC.Visible = False
X10ControllerD.Visible = False
X10ControllerE.Visible = False
X10ControllerF.Visible = False
X10ControllerG.Visible = False
X10ControllerH.Visible = False
X10ControllerI.Visible = False
X10ControllerJ.Visible = False
X10ControllerK.Visible = False
X10ControllerL.Visible = False
X10ControllerM.Visible = False
X10ControllerN.Visible = True
X10ControllerO.Visible = False
X10ControllerP.Visible = False
End If

If Combo30000.Text = "O" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = False
X10ControllerC.Visible = False
X10ControllerD.Visible = False
X10ControllerE.Visible = False
X10ControllerF.Visible = False
X10ControllerG.Visible = False
X10ControllerH.Visible = False
X10ControllerI.Visible = False
X10ControllerJ.Visible = False
X10ControllerK.Visible = False
X10ControllerL.Visible = False
X10ControllerM.Visible = False
X10ControllerN.Visible = False
X10ControllerO.Visible = True
X10ControllerP.Visible = False
End If

If Combo30000.Text = "P" Then
X10ControllerA.Visible = False
X10ControllerB.Visible = False
X10ControllerC.Visible = False
X10ControllerD.Visible = False
X10ControllerE.Visible = False
X10ControllerF.Visible = False
X10ControllerG.Visible = False
X10ControllerH.Visible = False
X10ControllerI.Visible = False
X10ControllerJ.Visible = False
X10ControllerK.Visible = False
X10ControllerL.Visible = False
X10ControllerM.Visible = False
X10ControllerN.Visible = False
X10ControllerO.Visible = False
X10ControllerP.Visible = True
End If
Combo30000.Text = ""
End Sub

Private Sub Combo40000_KeyPress(KeyAscii As Integer)
Char = Chr(KeyAscii)
KeyAscii = Asc(UCase(Char))
End Sub
   
Private Sub Command1_Click()
If Option1(1).Value = True Then
Text1.ForeColor = &HFF00&
Text1.BackColor = &HFF00&
Text1.Text = Frame1.Tag + " ON"
ActiveHome1.SendAction "sendplc", Text1.Text
End If
If Option1(0).Value = True Then
Text1.ForeColor = &HFF&
Text1.BackColor = &HFF&
Text1.Text = Frame1.Tag + " OFF"
ActiveHome1.SendAction "sendplc", Text1.Text
End If
End Sub

Private Sub Command100_Click()
Option1(0).Value = False
Option1(1).Value = False
Text1.Text = ""
Text1.BackColor = &H80000005
End Sub

Private Sub Command2_Click()
If Option2(1).Value = True Then
Text2.ForeColor = &HFF00&
Text2.BackColor = &HFF00&
Text2.Text = Frame2.Tag + " ON"
ActiveHome1.SendAction "sendplc", Text2.Text
End If
If Option2(0).Value = True Then
Text2.ForeColor = &HFF&
Text2.BackColor = &HFF&
Text2.Text = Frame2.Tag + " OFF"
ActiveHome1.SendAction "sendplc", Text2.Text
End If
End Sub

Private Sub Command200_Click()
Option2(0).Value = False
Option2(1).Value = False
Text2.Text = ""
Text2.BackColor = &H80000005
End Sub

Private Sub Command3_Click()
If Option3(1).Value = True Then
Text3.ForeColor = &HFF00&
Text3.BackColor = &HFF00&
Text3.Text = Frame3.Tag + " ON"
ActiveHome1.SendAction "sendplc", Text3.Text
End If
If Option3(0).Value = True Then
Text3.ForeColor = &HFF&
Text3.BackColor = &HFF&
Text3.Text = Frame3.Tag + " OFF"
ActiveHome1.SendAction "sendplc", Text3.Text
End If
End Sub

Private Sub Command300_Click()
Option3(0).Value = False
Option3(1).Value = False
Text3.Text = ""
Text3.BackColor = &H80000005
End Sub

Private Sub Command4_Click()
If Option4(1).Value = True Then
Text4.ForeColor = &HFF00&
Text4.BackColor = &HFF00&
Text4.Text = Frame4.Tag + " ON"
ActiveHome1.SendAction "sendplc", Text4.Text
End If
If Option4(0).Value = True Then
Text4.ForeColor = &HFF&
Text4.BackColor = &HFF&
Text4.Text = Frame4.Tag + " OFF"
ActiveHome1.SendAction "sendplc", Text4.Text
End If
End Sub

Private Sub Command400_Click()
Option4(0).Value = False
Option4(1).Value = False
Text4.Text = ""
Text4.BackColor = &H80000005
End Sub

Private Sub Command5_Click()
If Option5(1).Value = True Then
Text5.ForeColor = &HFF00&
Text5.BackColor = &HFF00&
Text5.Text = Frame5.Tag + " ON"
ActiveHome1.SendAction "sendplc", Text5.Text
End If
If Option5(0).Value = True Then
Text5.ForeColor = &HFF&
Text5.BackColor = &HFF&
Text5.Text = Frame5.Tag + " OFF"
ActiveHome1.SendAction "sendplc", Text5.Text
End If
End Sub

Private Sub Command500_Click()
Option5(0).Value = False
Option5(1).Value = False
Text5.Text = ""
Text5.BackColor = &H80000005
End Sub

Private Sub Command6_Click()
If Option6(1).Value = True Then
Text6.ForeColor = &HFF00&
Text6.BackColor = &HFF00&
Text6.Text = Frame6.Tag + " ON"
ActiveHome1.SendAction "sendplc", Text6.Text
End If
If Option6(0).Value = True Then
Text6.ForeColor = &HFF&
Text6.BackColor = &HFF&
Text6.Text = Frame6.Tag + " OFF"
ActiveHome1.SendAction "sendplc", Text6.Text
End If
End Sub

Private Sub Command600_Click()
Option6(0).Value = False
Option6(1).Value = False
Text6.Text = ""
Text6.BackColor = &H80000005
End Sub

Private Sub Command7_Click()
If Option7(1).Value = True Then
Text7.ForeColor = &HFF00&
Text7.BackColor = &HFF00&
Text7.Text = Frame7.Tag + " ON"
ActiveHome1.SendAction "sendplc", Text7.Text
End If
If Option7(0).Value = True Then
Text7.ForeColor = &HFF&
Text7.BackColor = &HFF&
Text7.Text = Frame7.Tag + " OFF"
ActiveHome1.SendAction "sendplc", Text7.Text
End If
End Sub

Cheers!
Logged

philliec

  • Full Member
  • ***
  • Helpful Post Rating: 1
  • Posts: 31
Re: Rabbits Visual Basic ToyBox
« Reply #8 on: June 13, 2008, 01:53:58 AM »

This looks great. Nice work. How do you get the code or exe?
Logged
Craig

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 283
  • Posts: 10509
  • I don't work for X10, I use it successfuly!
Re: Rabbits Visual Basic ToyBox
« Reply #9 on: June 13, 2008, 08:09:43 AM »

 -:) A PM to Rabbit supplying your e-mail address will most likely result it your recieving the info you'd like! :' ;)
>!
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

Rabbit

  • Full Member
  • ***
  • Helpful Post Rating: 6
  • Posts: 33
Re: Rabbits Visual Basic ToyBox
« Reply #10 on: June 20, 2008, 04:49:33 PM »

Well, I scrapped the previous version - in favor of this version!  -:)

This version is much cleaner, AND it is fed from an Excel Spreadsheet, so I don't have to modify the VB program. Just update the spreadsheet, and it appears in the VB program when it's run.

I've programmed it to recognize the Light Bulb as a normal light module and an appliance module - without the dim/bright feature. When I select All Lights On, the appliance modules that are used as lights turn on.

The programming is extensive (16 Forms) and I'm only finished with HC-A,B,C. It takes about an hour to create each form.

Here are three images - The first one shown is in the VB design mode, the second one as a running program, and the last as the Excel spreadsheet.







Cheers!
« Last Edit: June 20, 2008, 04:56:54 PM by Rabbit »
Logged

Rabbit

  • Full Member
  • ***
  • Helpful Post Rating: 6
  • Posts: 33
Rabbits Visual Basic ToyBox
« Reply #11 on: July 29, 2008, 09:34:51 PM »

Sorry... It's been a while since I last posted here... I'VE BEEN BUSY WRITING CODE!!!!!  ;D

Well, I've made significant progress and major improvements and enhancements. By using a "control array", I've eliminated 15 VB forms by using a control array - and reduced the size of the program from 23 Megs to 9 Megs. The earlier versions could only send X10 commands. I've found a way to receive commands as well  - RF commands from remotes as well as powerline commands. It took some instring searches to break down enough of the command to get it working right. The X10 Command line was the hardest to code.

The control array was a major acheivement. It took several attempts to get it right. VB has a limit of 256 controls! By using an array, I was able to bypass that limit (up to 32000 controls - 265 X 16 = 32000). The results were well worth it in the end. Everything works faster and more reliably. I also built an X10 Start form which allows choosing which House Code to go to when the program is run. I also incoporated a button to access the Excel spreadsheet directly. Another feature I just added allows all 256 HC/UC addresses to be seen at the same time. I used "balloons" (Tags) to identify which device is on each HC/UC using the same Excel spreadsheet as I use in the main program. Just place the cursor over the HC/UC number and it shows the balloon identification. The "View All" button is what activates the X10 Activity program.

One problem that I overcame was with the RF remotes. They send out funny numbers - 0, -1 , 0 ,-1 so I had to do a bit of work to ignore the RECVRF commands and only use the RECVPLC commands only. Got it working flawlessly!

I also added a yellow color to show a Dim or Bright setting. There's more but that's enough for now.

The first view is the VB design mode showing all the forms.

The second view shows the program running with the added X10 Activity program.

The third view is the modified Excel spreadsheet.







 >! ! Rabbit
Logged

Lennart

  • Newbie
  • Helpful Post Rating: 0
  • Posts: 1
Re: Rabbits Visual Basic ToyBox
« Reply #12 on: December 06, 2008, 09:48:19 AM »

Hi Rabbit, I am very interested in your Excel / VBA application that runs X10.  Any chanse you can share it?
Logged

hawk1

  • Hero Member
  • *****
  • Helpful Post Rating: 21
  • Posts: 625
Re: Rabbits Visual Basic ToyBox
« Reply #13 on: December 06, 2008, 10:50:21 AM »

that makes 2 of us. i also would like to try it out.  thanks
Logged
koopr@sstelco.com, I don't know what I'm doin but I'm havin fun doin it!

Rabbit

  • Full Member
  • ***
  • Helpful Post Rating: 6
  • Posts: 33
Re: Rabbits Visual Basic ToyBox
« Reply #14 on: December 07, 2008, 03:33:38 PM »

Thx! I've made additional modifications since I was last here. The X10 program now works with a camera and when activated (via VA11A), the program switches to the House Code associated with the camera. It works with remotes as well. I've also added the capability to select The X10 Controller or X10 Activity programs at startup or within either program. The program is 19 megabytes, and it would need to be zipped to email out. I'll work on it and get back to you.


 >! Crazy Rabbit  ;D
« Last Edit: December 09, 2008, 08:01:13 PM by Rabbit »
Logged
Pages: [1] 2
 

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