Dim rec_dou(100) As Double Dim rec As DoublePrivate Sub Form_Load() Text2.Text = Winsock1.LocalIP Text3.Text = Winsock1.LocalPort With Winsock1 .RemoteHost = "202.118.184.100" .RemotePort = 1088 .LocalPort = 2000 .Bind 2000End WithEnd SubPrivate Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Winsock1.GetData rec, vbDouble, 1 Dim s As String Dim count As Integer 'For count = 1 To 100 s = Str(rec)If Text1.Text = "" Then Text1.Text = s Else Text1.Text = Text1.Text & vbCrLf & s End If 'Next count End Sub 出错程序代码如上
benyfeifei(狒狒) 报错说这个CopyMemory函数没有定义是怎么回事啊?
我倒 CopyMemory是API函数啊。把下面的语句放到Module里。 Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)Dim rec_dou(100) As Double Dim rec As Double...Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long) Dim ab() As Byte ReDim ab(bytesTotal - 1) Winsock1.GetData ab, vbArray + vbByte CopyMemory rec_dou(0), ab(0), bytesTotal ...End Sub
CopyMemory ByVal VarPtr(bytData(0)), ByVal VarPtr(dblData(0)), UBound(bytData) + 1'再传送bytData数组就OK了。
VC发送char数组给vb,vb再4个字节的解析
我一直编vc最近才做vb,用得还不熟,希望大家多多指教!
我现在在试大家的建议,有结果我回发到帖子上。
......
Dim rec As DoublePrivate Sub Form_Load()
Text2.Text = Winsock1.LocalIP
Text3.Text = Winsock1.LocalPort
With Winsock1
.RemoteHost = "202.118.184.100"
.RemotePort = 1088
.LocalPort = 2000
.Bind 2000End WithEnd SubPrivate Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Winsock1.GetData rec, vbDouble, 1
Dim s As String
Dim count As Integer
'For count = 1 To 100
s = Str(rec)If Text1.Text = "" Then
Text1.Text = s
Else
Text1.Text = Text1.Text & vbCrLf & s
End If
'Next count
End Sub
出错程序代码如上
报错说这个CopyMemory函数没有定义是怎么回事啊?
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Dim rec As Double...Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim ab() As Byte
ReDim ab(bytesTotal - 1) Winsock1.GetData ab, vbArray + vbByte CopyMemory rec_dou(0), ab(0), bytesTotal
...End Sub