0

Im useng visual basic to make a control program for a usb relay board

This is the c# code that i know works

private void button1_ON_Click(object sender, EventArgs e)
        {
            serialPort1.Write(new byte[] { 0xFF, 0x01, 0x01 }, 0, 3);
            panel1.BackColor = Color.Lime;
        }

or
VB 6

Private Sub cmdOn_Click()
With MSComm1
'make sure the serial port is open
If .PortOpen = False Then .PortOpen = True
'send the data
.Output = Chr$(255)
.Output = Chr$(1)
.Output = Chr$(1)
End With 'MSComm1
End Sub

Any ideas on how to get it to work for VB? I really dont want to rewrite the entire thing, any help much appicated.

Oh the ff 01 01 controls the realy

ff: not sure
01: the realy number
01: Turn the relay on

Also im useing vb express 2008
if that helps at all

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by Jx_Man
0

private void button1_ON_Click(object sender, EventArgs e)
{
serialPort1.Write(new byte[] { 0xFF, 0x01, 0x01 }, 0, 3);
panel1.BackColor = Color.Lime;
}

C# code above become in this following code :

Private Sub button1_ON_Click(ByVal sender As Object, ByVal e As EventArgs)
    serialPort1.Write(New Byte() {255, 1, 1}, 0, 3)
	panel1.BackColor = Color.Lime
End Sub
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.