<big id="a5mua"></big>

      <tt id="a5mua"><dfn id="a5mua"></dfn></tt>
      <wbr id="a5mua"><sup id="a5mua"></sup></wbr>

        
        

      1. 亚洲综合小综合中文字幕,国产久爱免费精品视频,精品国产品香蕉在线,国产午夜精品在人线播放,精品一二三四区在线观看,国产成人无码免费看视频软件 ,色欲久久人妻内射,午夜在线观看成人av
        dongxuan24
        級別: 正式會員
        精華主題: 0
        發帖數量: 30 個
        工控威望: 96 點
        下載積分: 536 分
        在線時間: 6(小時)
        注冊時間: 2010-01-14
        最后登錄: 2012-07-12
        查看dongxuan24的 主題 / 回貼
        樓主  發表于: 2010-08-19 10:46
        Private Sub Combo5_Click()
           Select Case Combo5.Text
             Case "On"
                Instruction = &H11
             Case "Off"
                Instruction = &H10
           End Select
        End Sub

        Private Sub Command1_Click()
           Dim OutByte(0 To 32) As Byte
           Dim Num As Double
           Dim Num2 As String
           Dim L
           Dim Lenth2 As String
           Dim ByteXor As Byte
           Dim StrXor As String
          
           ReadPlc = True
           If Text1.Text = "" Then
             MsgBox "請輸入寄存器地址", vbOKOnly, "系統提示"
           Else
             Num = Val(Text1.Text)
             Num2 = Hex(Num)
             Lenth2 = Hex(Lenth)
             ByteXor = 0
            
             OutByte(0) = 103           '起始字符
             OutByte(1) = 5             '讀寫指令
             OutByte(2) = Asc(0)        'PLC站地址
             OutByte(3) = Asc(2)
             OutByte(4) = Asc(Mid(Address_R, 1, 1))    '寄存器類型
             OutByte(5) = Asc(Mid(Address_R, 2, 1))
             OutByte(6) = Asc(Mid(Address_R, 3, 1))
             OutByte(7) = Asc(Mid(Address_R, 4, 1))
            
             L = Len(Num2)                          '寄存器地址
             For i = 0 To L - 1
               OutByte(11 - i) = Asc(Mid(Num2, L - i, 1))
             Next i
             For i = 0 To 3 - L
               OutByte(11 - L - i) = Asc(0)
             Next i
            
             L = Len(Lenth2)                      '讀取字節數
             If L = 2 Then
               OutByte(12) = Asc(Mid(Lenth2, 1, 1))
               OutByte(13) = Asc(Mid(Lenth2, 2, 1))
             Else
               OutByte(12) = Asc(0)
               OutByte(13) = Asc(Mid(Lenth2, 1, 1))
             End If
            
             For i = 1 To 29                        'BCC校驗碼計算
               ByteXor = ByteXor Xor OutByte(i)
             Next i
             StrXor = Hex(ByteXor)
             If Len(StrXor) = 2 Then
               OutByte(30) = Asc(Mid(StrXor, 1, 1))
               OutByte(31) = Asc(Mid(StrXor, 2, 1))
             Else
               OutByte(30) = Asc(0)
               OutByte(31) = Asc(Mid(StrXor, 1, 1))
             End If
             OutByte(32) = 71
           End If
           MSComm1.Output = OutByte
        End Sub


        Private Sub Command2_Click()
        Dim OutByte(0 To 32) As Byte
           Dim Num As Double
           Dim Num2 As String
           Dim L
           Dim Lenth2 As String
           Dim ByteXor As Byte
           Dim StrXor As String
           Dim Data_Send  As Double
           Dim Data_Send2 As String
           Dim SetLenth2 As String
          
           Read = False
           If Text2.Text = "" Then
             MsgBox "請輸入寄存器地址", vbOKOnly, "系統提示"
           Else
             Num = Val(Text2.Text)
             Num2 = Hex(Num)
            
             SetLenth2 = Hex(SetLenth * 2)
            
             Data_Send = Val(Text4.Text)
             Data_Send2 = Hex(Data_Send)
              
             ByteXor = 0
            
             OutByte(0) = 103           '起始字符
             OutByte(1) = 6             '指令寫
             OutByte(2) = Asc(0)        'PLC站地址
             OutByte(3) = Asc(2)
             OutByte(4) = Asc(Mid(Address_W, 1, 1))      '寄存器類型
             OutByte(5) = Asc(Mid(Address_W, 2, 1))
             OutByte(6) = Asc(Mid(Address_W, 3, 1))
             OutByte(7) = Asc(Mid(Address_W, 4, 1))
            
             L = Len(Num2)                             '寄存器地址
             For i = 0 To L - 1
               OutByte(11 - i) = Asc(Mid(Num2, L - i, 1))
             Next i
             For i = 0 To 3 - L
               OutByte(11 - L - i) = Asc(0)
             Next i
            
             L = Len(SetLenth2)            '寫入數據的長度
             If L = 2 Then
               OutByte(12) = Asc(Mid(SetLenth2, 1, 1))
               OutByte(13) = Asc(Mid(SetLenth2, 2, 1))
             Else
               OutByte(12) = Asc(0)
               OutByte(13) = Asc(Mid(SetLenth2, 1, 1))
             End If
             '寫入PLC的數據
             L = Len(Data_Send2)
             For i = 1 To L
               OutByte(14 + 2 * SetLenth - i) = Asc(Mid(Data_Send2, L - i + 1, 1))
             Next i
             For i = 1 To SetLenth * 2 - L
               OutByte(13 + i) = Asc(0)
             Next i
            
            
            
            
             '寫入PLC的數據
             For i = 1 To 29                     'BCC校驗碼計算
               ByteXor = ByteXor Xor OutByte(i)
             Next i
             StrXor = Hex(ByteXor)
             If Len(StrXor) = 2 Then
               OutByte(30) = Asc(Mid(StrXor, 1, 1))
               OutByte(31) = Asc(Mid(StrXor, 2, 1))
             Else
               OutByte(30) = Asc(0)
               OutByte(31) = Asc(Mid(StrXor, 1, 1))
             End If
             OutByte(32) = 71
           End If
           MSComm1.Output = OutByte
        End Sub

        Private Sub Command3_Click()
           Dim OutByte(0 To 32) As Byte
           Dim Num As Double
           Dim Num2 As String
           Dim L
           Dim Lenth2 As String
           Dim ByteXor As Byte
           Dim StrXor As String
          
           ReadPlc = False
           If Text6.Text = "" Then
             MsgBox "請輸入寄存器地址", vbOKOnly, "系統提示"
           Else
             Num = Val(Text6.Text)
             Num2 = Hex(Num)
             Lenth2 = Hex(Lenth)
             ByteXor = 0
            
             OutByte(0) = 103                         '起始字符
             OutByte(1) = Instruction                 '讀寫指令
             OutByte(2) = Asc(0)                      'PLC站地址
             OutByte(3) = Asc(2)
             OutByte(4) = Asc(Mid(Address_B, 1, 1))     '寄存器類型
             OutByte(5) = Asc(Mid(Address_B, 2, 1))
             OutByte(6) = Asc(Mid(Address_B, 3, 1))
             OutByte(7) = Asc(Mid(Address_B, 4, 1))
            
             L = Len(Num2)                           '寄存器地址
             For i = 0 To L - 1
               OutByte(11 - i) = Asc(Mid(Num2, L - i, 1))
             Next i
             For i = 0 To 3 - L
               OutByte(11 - L - i) = Asc(0)
             Next i
            
                                                     '位地址
            
               OutByte(12) = Asc(Mid(Bit, 1, 1))
               OutByte(13) = Asc(Mid(Bit, 2, 1))
            

            
             For i = 1 To 29                        'BCC校驗碼計算
               ByteXor = ByteXor Xor OutByte(i)
             Next i
             StrXor = Hex(ByteXor)
             If Len(StrXor) = 2 Then
               OutByte(30) = Asc(Mid(StrXor, 1, 1))
               OutByte(31) = Asc(Mid(StrXor, 2, 1))
             Else
               OutByte(30) = Asc(0)
               OutByte(31) = Asc(Mid(StrXor, 1, 1))
             End If
             OutByte(32) = 71
           End If
           MSComm1.Output = OutByte
        End Sub

        Private Sub Form_Load()
           Instruction = &H11
           Address_R = "0100"
           Address_W = "0100"
           Address_B = "0100"
           Bit = "00"
           Lenth = 2
           SetLenth = 2
           MSComm1.CommPort = 1
           MSComm1.Settings = "9600,n,8,1"
           MSComm1.PortOpen = True
            If (Err) Then
               MsgBox "端口打開錯誤", vbOKOnly, "系統信息"
            End If
           MSComm1.RThreshold = 20
           MSComm1.InputMode = 1
           MSComm1.InBufferCount = 0
        End Sub



        Private Sub MSComm1_OnComm()
          Dim Temp() As Byte
          Dim Read(0 To 32) As Byte
          Dim BBC As Byte
          Dim XorByte As Byte
          Dim BBC_Temp As Byte
          Dim Value As Double
          Dim Trans(1 To 8) As Byte
          Dim TransValue As Double
          
          Value = 0
          XorByte = 0
          Temp = MSComm1.Input
          If ReadPlc = True Then
          
          If Temp(LBound(Temp)) = 103 And Temp(LBound(Temp) + 1) = 1 Then         '如果起始正確
              
              For i = 0 To 20
                Read(i) = Temp(i)
              Next i
              
              For i = 2 To 17                     '計算校驗碼
                 XorByte = XorByte Xor Read(i)
              Next i
              
              For i = 2 To 19
                If Read(i) > &H40 Then
                   Read(i) = Read(i) - &H37
                Else
                   Read(i) = Read(i) - &H30
                End If
              Next
              BBC_Temp = Read(19) + Read(18) * &H10
              If XorByte = BBC_Temp Then
              
                For i = 2 To Lenth * 2 + 1
                  
                  Value = Value * &H10 + Read(i)
                Next i
              Text3.Text = Value
              End If
          End If
          Else
             If Temp(0) = 103 And Temp(1) = 2 Then
               MsgBox "參數設定成功", vbOKOnly, "系統提示"
             End If
          End If
        End Sub


        尤其是這幾句,希望能具體解釋一下,多謝


        OutByte(0) = 103           '起始字符
             OutByte(1) = 5             '讀寫指令
             OutByte(2) = Asc(0)        'PLC站地址
             OutByte(3) = Asc(2)
             OutByte(4) = Asc(Mid(Address_R, 1, 1))    '寄存器類型
             OutByte(5) = Asc(Mid(Address_R, 2, 1))
             OutByte(6) = Asc(Mid(Address_R, 3, 1))
             OutByte(7) = Asc(Mid(Address_R, 4, 1))
            
             L = Len(Num2)                          '寄存器地址
             For i = 0 To L - 1
               OutByte(11 - i) = Asc(Mid(Num2, L - i, 1))
             Next i
             For i = 0 To 3 - L
               OutByte(11 - L - i) = Asc(0)
             Next i
            
             L = Len(Lenth2)                      '讀取字節數
             If L = 2 Then
               OutByte(12) = Asc(Mid(Lenth2, 1, 1))
               OutByte(13) = Asc(Mid(Lenth2, 2, 1))
             Else
               OutByte(12) = Asc(0)
               OutByte(13) = Asc(Mid(Lenth2, 1, 1))
             End If
            
             For i = 1 To 29                        'BCC校驗碼計算
               ByteXor = ByteXor Xor OutByte(i)
             Next i
             StrXor = Hex(ByteXor)
             If Len(StrXor) = 2 Then
               OutByte(30) = Asc(Mid(StrXor, 1, 1))
               OutByte(31) = Asc(Mid(StrXor, 2, 1))
             Else
               OutByte(30) = Asc(0)
               OutByte(31) = Asc(Mid(StrXor, 1, 1))
             End If
             OutByte(32) = 71
           End If
           MSComm1.Output = OutByte
        End Sub


        Private Sub Command2_Click()
        Dim OutByte(0 To 32) As Byte
           Dim Num As Double
           Dim Num2 As String
           Dim L
           Dim Lenth2 As String
           Dim ByteXor As Byte
           Dim StrXor As String
           Dim Data_Send  As Double
           Dim Data_Send2 As String
           Dim SetLenth2 As String
          
           Read = False
           If Text2.Text = "" Then
             MsgBox "請輸入寄存器地址", vbOKOnly, "系統提示"
           Else
             Num = Val(Text2.Text)
             Num2 = Hex(Num)
            
             SetLenth2 = Hex(SetLenth * 2)
            
             Data_Send = Val(Text4.Text)
             Data_Send2 = Hex(Data_Send)
              
             ByteXor = 0
            
             OutByte(0) = 103           '起始字符
             OutByte(1) = 6             '指令寫
             OutByte(2) = Asc(0)        'PLC站地址
             OutByte(3) = Asc(2)
             OutByte(4) = Asc(Mid(Address_W, 1, 1))      '寄存器類型
             OutByte(5) = Asc(Mid(Address_W, 2, 1))
             OutByte(6) = Asc(Mid(Address_W, 3, 1))
             OutByte(7) = Asc(Mid(Address_W, 4, 1))
            
             L = Len(Num2)                             '寄存器地址
             For i = 0 To L - 1
               OutByte(11 - i) = Asc(Mid(Num2, L - i, 1))
             Next i
             For i = 0 To 3 - L
               OutByte(11 - L - i) = Asc(0)
             Next i
            
             L = Len(SetLenth2)            '寫入數據的長度
             If L = 2 Then
               OutByte(12) = Asc(Mid(SetLenth2, 1, 1))
               OutByte(13) = Asc(Mid(SetLenth2, 2, 1))
             Else
               OutByte(12) = Asc(0)
               OutByte(13) = Asc(Mid(SetLenth2, 1, 1))
             End If
             '寫入PLC的數據
             L = Len(Data_Send2)
             For i = 1 To L
               OutByte(14 + 2 * SetLenth - i) = Asc(Mid(Data_Send2, L - i + 1, 1))
             Next i
             For i = 1 To SetLenth * 2 - L
               OutByte(13 + i) = Asc(0)
             Next i
            

        主站蜘蛛池模板: 亚洲成av人片色午夜乱码| 久国产精品韩国三级视频| 插插射啊爱视频日a级| 美腿丝袜无男人的天堂| 九九热免费在线播放视频| 五月综合网亚洲乱妇久久| 99精品国产一区二区电影| 国产av区男人的天堂| 国产精品免费视频不卡| 少妇被躁到高潮人苞一| 国产精品一品二区三区日韩 | 亚洲av天堂综合网久久| 亚洲精品www久久久久久| 乱人伦人妻中文字幕无码久久网| 小嫩批日出水无码视频免费| 女被男啪到哭的视频网站| 亚洲最大成人在线播放| 中国CHINA体内裑精亚洲日本| 亚洲精品综合一区二区三区| 久爱无码精品免费视频在线观看 | 亚洲精品无码久久千人斩| 亚洲人成网站18禁止大app| 国产成人精品久久性色av| 国产精品无码不卡在线播放| 久热这里有精品视频在线| 丝袜国产一区av在线观看| 国产国语一级毛片| 亚洲成A人片在线观看的电影| 色婷婷五月在线精品视频| 人妻丝袜AV中文系列先锋影音| 日韩 欧美 动漫 国产 制服| 中文字幕日韩一区二区不卡| 狠狠色综合久久狠狠色综合| 综合图区亚洲另类偷窥| 国产粉嫩美女一区二区三| yw尤物av无码国产在线观看| 人妻无码ΑV中文字幕久久琪琪布| 国产尤物AV尤物在线看| 丁香婷婷色综合激情五月| 亚洲精品久久久久久久久毛片直播 | 三级三级三级a级全黄|