VC代码翻译成VB 6.0代码

来源:百度知道 编辑:UC知道 时间:2024/05/27 13:01:14
VC代码:

#define ChildMaxNum 50
typedef struct
{
unsigned char rootname[20];
unsigned char rootip[16];
short port;
unsigned char deviceID[4];
unsigned char name[20];
}T_ChildType;

要求数据结构一致,数据大小一致,如rootname占用20个字节,
VB代码中也要占用20个字节,因为我是同过socket接收数据的,
VB6中好像没有short类型,我对vb不太熟悉,以下是我的vb代码,
不知对不对

Private Type T_ChildType
rootname(0 To 19) As Byte
rootip(0 To 15) As Byte
port(0 To 2) As Byte
deviceID(0 To 3) As Byte
rootname(0 To 19) As Byte
End Type

如果我通过socket接收的数据是char recbuff[1000],
我在VC中可以这样写
T_ChildType childres[ChildMaxNum];
memcpy((void*)childres,recvBuf,size);
那么在VB中不知道怎么写,vb中有没有和memcpy相当
的函数?

一两句话说不清楚,给你个VC转换VB的参数表吧
大写的是c/c++参数类型,小写的是对应VB的参数类型
integer2字节
long 4字节
byte 1字节
string 是字符数*2
ATOM byval variable as integer
BOOL byval variable as long
BYTE byval variable as byte
CHAR byval variable as byte
COLORREF byval variable as long
DWORD byval variable as long
HWND,HDC,HMENU,etc.(windows handles)byval variable as long
INT,UINT byval variable as long
LONG byval variable as long
LPARAM byval variable as long
LPDWORD byval variable as long
LPINT,LPUINT byval variable as long
LPRECT byval variable as type
LPSTR,LPCSTR byval variable as string
LPVOID byval variable as any #any variable(use byval when passing a string)
LPWORD byval variable as integer
LRESULT byval variable as long
NULL as any or byval variable as long byval nothing or byval 0& or vbnullstring
(你说的short类型在下面)
SHORT byval variable as integer
VOID sub procedure
WORD byval variable