K8055 "time" code, please help

hi :} , i have only just taught myself some vb2008 having bought a k8055 interface board some time ago, not realizing that you needed to be able to write your own code
i am trying to make the digital output ( say channel 16 ) of my k8055 board turn on at 21:00hrs and off at 09:00hrs,
i bet i don’t need half the code that i have written and im missing something…but what
i have tried

'label8 is time
'checkbox4 is to activate the cct
'textbox3 is time on
'textbox4 is time off
'timer5 is to check time
'timer6 is turn output on
'timer7 is turn output off

Private Sub CheckBox4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox4.CheckedChanged
If CheckBox4.CheckState = 1 Then
Timer5.Enabled = True
End If
If CheckBox4.CheckState = 0 Then
ClearDigitalChannel(16) 'why dont this clear output7
ClearDigitalChannel(32)
ClearAllDigital()
Timer5.Enabled = False

    End If
End Sub
'timer for light on
Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick


    '        lights on 21:00                        
    If Label8.Text >= TextBox3.Text And Label8.Text <= TextBox4.Text Then
        Timer6.Enabled = True
        Timer7.Enabled = False
    End If
    '        lights off 09:00
    If Label8.Text >= TextBox3.Text And Label8.Text >= TextBox4.Text Then
        Timer6.Enabled = False
        Timer7.Enabled = True
    End If

End Sub

Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick
    If Timer6.Enabled = True Then
        WriteAllDigital(16)
        PictureBox1.Visible = True
        PictureBox2.Visible = False
    End If
    If Timer6.Enabled = False Then
        ClearAllDigital()
        PictureBox1.Visible = False
        PictureBox2.Visible = True
    End If
End Sub

Private Sub Timer7_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer7.Tick
    If Timer7.Enabled = True Then
        ClearAllDigital()
        PictureBox1.Visible = False
        PictureBox2.Visible = True
    End If
    If Timer7.Enabled = False Then
        WriteAllDigital(16)
        PictureBox1.Visible = True
        PictureBox2.Visible = False
    End If
End Sub

but there is a problem …can u help ???

if the “off” time(0900) is less than the “on” time(2100) it will not run, it is ok if it’s on is at 0900 and off at 2100.
i could reverse the values but i want to be able to change times by textbox1 and 2 values…

pleeeeease help :}

[quote]ClearDigitalChannel(16) 'why dont this clear output7[/quote]The parameter of the ClearDigitalChannel should be 1 to 8.

[color=#000080]Parameter
Channel: Value between 1 and 8 which corresponds to the output channel that is to be cleared.[/color]

ah ha thank you thankyou thankyou,

to turn on channel 5 i have to write
writealldigital(16) "if i put (5) it turned on channel (1 and 3) …that confused me for a bit :laughing:

so i presumed ( being the m.o.a.f.u ) that to turn it off i would also use ch.(16)

any ideas about the 24 hour clock problem ive been struggling for days on it :confused:

thanks again

:wink:

There are nice functions in Visual Basic to get the current hour.
Here some code as an example:

[code] Dim ThisMoment As Date
’ The following statement calls the Get procedure of the Visual Basic Now property.
ThisMoment = Now

    Label24.Text = ThisMoment       ' just testing this function
    Label25.Text = Hour(ThisMoment) ' just testing this function

    If Hour(ThisMoment) = 9 Then
        ' turn lights off
    End If
    If Hour(ThisMoment) = 21 Then
        ' turn lights on
    End If[/code]

Please follow this link to find more info…
msdn.microsoft.com/en-us/library/sh9ywfdk.aspx

thanks for the procedure i will try it,