Option Strict On Imports System.IO Imports System.Net Imports System.Net.Sockets Imports System.Text Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Call cmd11chk(&H11, &H0, &H0) Call cmd12chk(&H12, &H0, &H0) Call cmd13chk(&H13, &H0, &H0) End Sub Sub sendcmd2(ByVal ipstring As String, ByVal Rcmd As Byte, ByVal Dat1 As Byte, ByVal Dat2 As Byte, ByVal rdat() As Byte) Dim Xpsocket As Socket Dim rn As Integer Dim xpstream As NetworkStream Dim Binwriter As BinaryWriter Dim Binreader As BinaryReader Dim Sdat(8) As Byte For rn = 0 To 8 Sdat(rn) = 0 Next rn Sdat(0) = Rcmd Sdat(1) = Dat1 Sdat(5) = Dat2 TextBox1.Text = "" For rn = 0 To 8 TextBox1.Text = TextBox1.Text + Hex(Sdat(rn)) + "*" Next rn Xpsocket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp) 'MessageBox.Show(ipstring) Xpsocket.Connect(ipstring, 30704) xpstream = New NetworkStream(Xpsocket) Binwriter = New BinaryWriter(xpstream) Binreader = New BinaryReader(xpstream) Binwriter.Write(Sdat) Binwriter.Flush() TextBox2.Text = "" For rn = 0 To 4 rdat(rn) = Binreader.ReadByte TextBox2.Text = TextBox2.Text + Hex(rdat(rn)) + "*" Next rn Xpsocket.Close() End Sub Sub cmd11chk(ByVal Cmd As Byte, ByVal Dat1 As Byte, ByVal Dat2 As Byte) Dim rdata(4) As Byte Call sendcmd2(ComboBox1.Text, Cmd, Dat1, Dat2, rdata) If (&H1 And rdata(1)) = &H1 Then Label7.ForeColor = Color.Red ChkOut1.Checked = True Else Label7.ForeColor = Color.Black ChkInput1.Checked = True End If If (&H2 And rdata(1)) = &H2 Then Label8.ForeColor = Color.Red ChkOut2.Checked = True Else Label8.ForeColor = Color.Black ChkInput2.Checked = True End If If (&H4 And rdata(1)) = &H4 Then Label9.ForeColor = Color.Red ChkOut3.Checked = True Else Label9.ForeColor = Color.Black ChkInput3.Checked = True End If End Sub Sub cmd12chk(ByVal Cmd As Byte, ByVal Dat1 As Byte, ByVal Dat2 As Byte) Dim rdata(4) As Byte Call sendcmd2(ComboBox1.Text, Cmd, Dat1, Dat2, rdata) If (&H1 And rdata(1)) = &H1 Then Label4.ForeColor = Color.Red P1acth.Checked = True Else Label4.ForeColor = Color.Black P1actL.Checked = True End If If (&H2 And rdata(1)) = &H2 Then Label5.ForeColor = Color.Red P2acth.Checked = True Else Label5.ForeColor = Color.Black P2actL.Checked = True End If If (&H4 And rdata(1)) = &H4 Then Label6.ForeColor = Color.Red P3acth.Checked = True Else Label6.ForeColor = Color.Black P3actL.Checked = True End If End Sub Sub cmd13chk(ByVal Cmd As Byte, ByVal Dat1 As Byte, ByVal Dat2 As Byte) Dim rdata(4) As Byte Call sendcmd2(ComboBox1.Text, Cmd, Dat1, Dat2, rdata) If (&H1 And rdata(1)) = &H1 Then Label1.ForeColor = Color.Red p1don.Checked = True Else Label1.ForeColor = Color.Black P1doff.Checked = True End If If (&H2 And rdata(1)) = &H2 Then Label2.ForeColor = Color.Red p2don.Checked = True Else Label2.ForeColor = Color.Black P2doff.Checked = True End If If (&H4 And rdata(1)) = &H4 Then Label3.ForeColor = Color.Red p3don.Checked = True Else Label3.ForeColor = Color.Black P3doff.Checked = True End If End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click Call cmd11chk(&H11, &H0, &H0) End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click Dim par2 As Byte par2 = 0 If ChkOut1.Checked = True Then par2 = CByte(par2 + 1) End If If ChkOut2.Checked = True Then par2 = CByte(par2 + 2) End If If ChkOut3.Checked = True Then par2 = CByte(par2 + 4) End If Call cmd11chk(&H19, &H7, par2) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Call cmd12chk(&H12, &H0, &H0) End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim par2 As Byte par2 = 0 If P1acth.Checked = True Then par2 = CByte(par2 + 1) End If If P2acth.Checked = True Then par2 = CByte(par2 + 2) End If If P3acth.Checked = True Then par2 = CByte(par2 + 4) End If Call cmd12chk(&H1A, &H7, par2) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Call cmd13chk(&H13, &H0, &H0) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim par2 As Byte par2 = 0 If p1don.Checked = True Then par2 = CByte(par2 + 1) End If If p2don.Checked = True Then par2 = CByte(par2 + 2) End If If p3don.Checked = True Then par2 = CByte(par2 + 4) End If Call cmd13chk(&H1B, &H7, par2) End Sub End Class