Solved

Converting some C++ definitions to VB6

Posted on 2008-06-20
2
204 Views
Last Modified: 2010-04-30
Hi guys,

I've been given the following code and need to get it to work in VB6. I don't necessarily need them all doing, but if you could advise me on what to replace with what to get the correct definitions in VB6 I'd really appreciate it.

Cheers,

Bob
typedef struct MsgsBlock

	{

	int				StructSize;

	int				ReturnCode;

	int				Flags;							// ProtData flags:	BIT0 = trial, BIT1 = non-web

	char			ProductKey[(MAX_PRODKEY_LEN+3)&0xfc]; // 30 bytes (16+13+1) rounded up to multiple of 4 bytes = 32

	int				NextRefresh;

	int				LocalExecsLeft;

	int				Expiry;	

	int				Features;

	int				MaxNetUsers;						// -1 = no limit

	int				WebExecsLeft;						// -1 = no limit

	char			ProductCode[MAX_PRODCODE_LEN+1];	// 17 bytes

	char			ExtendedError[32];

	} MSGSBLOCK;
 

#define	COMPANY_OPTIONAL	1

#define	COMPANY_REQUIRED	2

#define	NAME_OPTIONAL		4

#define	NAME_REQUIRED		8

#define	HOUSE_OPTIONAL		16

#define	HOUSE_REQUIRED		32

#define	STREET_OPTIONAL		64

#define	STREET_REQUIRED		128

#define	TOWN_OPTIONAL		256

#define	TOWN_REQUIRED		0x200

#define	COUNTY_OPTIONAL		0x400

#define	COUNTY_REQUIRED		0x800

#define	POSTCODE_OPTIONAL	0x1000

#define	POSTCODE_REQUIRED	0x2000

#define	COUNTRY_OPTIONAL	0x4000

#define	COUNTRY_REQUIRED	0x8000

#define	PHONE_OPTIONAL		0x10000

#define	PHONE_REQUIRED		0x20000

#define	EMAIL_OPTIONAL		0x40000

#define	EMAIL_REQUIRED		0x80000

#define EMAIL_VERIFY		0x100000		// Email required and verification required
 
 

typedef struct MsgsCountry

{

char	Code[4];

char	Name[40];

} MSGS_COUNTRY;
 

typedef struct MsgsRegInfoTag

	{

	char Name[51];

	char Company[51];

	char Address1[51];

	char Address2[51];

	char Address3[51];

	char Address4[51];

	char PostCode[11];

	char Country[4];

	char Tel[21];

	char email[51];

	} MSGS_REGINFO;

Open in new window

0
Comment
Question by:Bobeo
2 Comments
 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
ID: 21836344
Here's a first pass (in the snippet)
Type MsgsBlock

    StructSize      As Long

    ReturnCode      As Long

    Flags           As Long            ' ProtData flags:  BIT0 = trial, BIT1 = non-web

    ProductKey(1 To 32)     As Byte    ' 30 bytes (16+13+1) rounded up to multiple of 4 bytes = 32

    'ProductKey     As string * 32    ' 30 bytes (16+13+1) rounded up to multiple of 4 bytes = 32

    NextRefresh     As Long

    LocalExecsLeft  As Long

    Expiry          As Long

    Features        As Long

    MaxNetUsers     As Long            ' -1 = no limit

    WebExecsLeft    As Long            ' -1 = no limit

    ProductCode(1 To 17)    As Byte    ' 17 bytes

    'ProductCode    As string * 17   ' 17 chars

    ExtendedError(1 To 32)  As Byte

    'ExtendedError As string * 32

End Type
 

Const COMPANY_OPTIONAL   As Long = 1

Const COMPANY_REQUIRED   As Long = 2

Const NAME_OPTIONAL      As Long = 4

Const NAME_REQUIRED      As Long = 8

Const HOUSE_OPTIONAL     As Long = 16

Const HOUSE_REQUIRED     As Long = 32

Const STREET_OPTIONAL    As Long = 64

Const STREET_REQUIRED    As Long = 128

Const TOWN_OPTIONAL      As Long = 256

Const TOWN_REQUIRED      As Long = &H200

Const COUNTY_OPTIONAL    As Long = &H400

Const COUNTY_REQUIRED    As Long = &H800

Const POSTCODE_OPTIONAL  As Long = &H1000

Const POSTCODE_REQUIRED  As Long = &H2000

Const COUNTRY_OPTIONAL   As Long = &H4000

Const COUNTRY_REQUIRED   As Long = &H8000

Const PHONE_OPTIONAL     As Long = &H10000

Const PHONE_REQUIRED     As Long = &H20000

Const EMAIL_OPTIONAL     As Long = &H40000

Const EMAIL_REQUIRED     As Long = &H80000

Const EMAIL_VERIFY       As Long = &H100000        ' Email required and verification required

 

 

Type MsgsCountry

    Code As String * 4

    Name As String * 40

End Type

 

Type MsgsRegInfoTag

    Name As String * 51

    Company As String * 51

    Address1 As String * 51

    Address2 As String * 51

    Address3 As String * 51

    Address4 As String * 51

    PostCode As String * 11

    Country As String * 4

    Tel As String * 21

    email As String * 51

End Type

Open in new window

0
 
LVL 3

Author Closing Comment

by:Bobeo
ID: 31469357
Spot on! Thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now