Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Convert this struct to a vb type :\

This topic is 5617 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is the struct in VC.
struct __attribute__((packed)) {
	BYTE id;
	BYTE gn;
	BYTE status;
	char creator[16];
	BYTE type;
	BYTE scorelimit;
	BYTE timelimit;
	BYTE playerlimit;
	char name[31];
	char mapauthor[16];
	char mapname[31];
	BYTE teams;
	BYTE pwdprotect;
	BYTE teamscore[4];
	WORD fanfare;
} gameinfo;
This is what i converted it to.
Public Type GameInfo
    id As Byte
    gn As Byte
    status As Byte
    creator As String * 16
    type As Byte
    scorelimit As Byte
    timelimit As Byte
    playerlimit As Byte
    name As String * 31
    mapauthor As String * 16
    mapname As String * 31
    teams As Byte
    pwdprotect As Byte
    teamscore(4) As Byte
    fanfare As Integer
End Type
hmmm... i seeme to have an invalid length or so, could anyone check it please? thanx [edited by - -Fruz- on June 4, 2003 8:05:38 AM]

Share this post

Link to post
Share on other sites
By default, most C++ compilers will add a couple dummy bytes to the front of a struct to make its length a multiple of 4.

You can account for that, or just turn it off with:

#pragma pack(1)

(I think)

Share this post

Link to post
Share on other sites
Your C/C++ char arrays have to account for a NULL-terminator. I don''t *think* VB''s fixed-length strings include this in their length. So (I think)

char name[31];

will become

name As String *30

I may be wrong though, it''s a while since I used VB...

Share this post

Link to post
Share on other sites
In MS Visual Studio, there''s a tool included that converts win API declarations in C to VB-declarations. You''ll find it under
"Microsoft Visual Studio 6.0 Tools/API Text Viewer". You can just load any C-file you want.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!