i am trying to write a program to controll a usb relay board. i have got everything working they way i would like except for one issue. when i debug my program, or publsih it and run it, i can not controll the usb board unless i open up the test software that came with the relay board and then close the test software. then my program will controll the usb relay board fine and with no issues untill i unplug the usb cable. when i plug the usb back in i have to open and close the test software again for my program to controll the board.
Private Sub three()
Form4.Label1.Text = AutoDetect()
SerialPort1.BaudRate = Form4.Label2.Text
SerialPort1.DataBits = 8
End Sub
Sub RELAYON()
Dim data(3) As Byte
data(0) = 0
data(1) = 0
If (Form2.Label2.Text) = 1 Then data(2) = 1
If (Form2.Label2.Text) = 2 Then data(2) = 2
If (Form2.Label2.Text) = 3 Then data(2) = 4
If (Form2.Label2.Text) = 4 Then data(2) = 8
SerialPort1.PortName = "COM" + Form4.Label1.Text
SerialPort1.Open()
SerialPort1.Write(data, 0, 3)
SerialPort1.Close()
End Sub
Sub RELAYOFF()
Dim data(2) As Byte
data(0) = 0
data(1) = 0
data(2) = 0
SerialPort1.PortName = "COM" + Form4.Label1.Text
SerialPort1.Open()
SerialPort1.Write(data, 0, 3)
SerialPort1.Close()
End Sub