标题:VB通过UDP发送16进制数据0x01
只看楼主
hongyb
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2018-3-16
得分:0 
回复 9楼 wds1
谢谢版主:终于搞通了,十分感谢!

          Dim udhi(31) As Byte '定义头数组
          Dim txt() As Byte '定义正文数组
          Dim Send_data()  As Byte
         
          '下面部分也可以定义结构体
          Dim No1 As Long
          Dim No2 As Long
          Dim ip As String
           
          Dim len1 As Long
          Dim Txt1 As String
         '赋值
          No1 = 1
          No2 = 2

          Txt1 = "000000"
          len1 = LenB(Txt1)
         
          Txt2 = "192.168.1.2测试测试........."
         
         '数据转为数组
          CopyMemory udhi(0), No1, 4
          CopyMemory udhi(4), No2, 4
         

          CopyMemory udhi(31), len1, 4
        
          txt = StrConv(Txt2, vbFromUnicode)
         
          ReDim Send_data(UBound(udhi) + UBound(txt) + 1)
         
          For i = 0 To 31: Send_data(i) = udhi(i): Next
          For i = 0 To UBound(txt): Send_data(32 + i) = txt(i): Next i
         
          Winsock1.SendData Send_data
2018-03-20 17:34



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-485327-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017441 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved