Advertisement

VB Types =? C Struct/Class

Started by November 16, 2000 08:36 PM
4 comments, last by vbisme 24 years, 1 month ago
let''s say I have in VB: Type SomeThing myInt As Integer End Type and in C: class SomeThing { public: int myInt; }; If I want to save these to a binary file, can I open the structure in C++ and well as Visual Basic interchangably?
If you''re smart about it you can. For example, write out the elements of the struct/class/Type out one at a time in the same way. Also restrict yourself to types common to both C++ and VB, especially don''t use Variant variable types in VB, unless you can guarantee the conversion into a C++ type.
Advertisement
THE VB TYPE declaration is language equal to the struct in c/c++, they are both data types, and can be trated like the standard int, char ....
c/c++/Java/Delphi/VB
quote:
THE VB TYPE declaration is language equal to the struct in c/c++, they are both data types, and can be trated like the standard int, char ....


Yeah, but the question is if they are "binary equal" (i.e. represented the same way in memory).
I found that most of them are. The Integer in VB is only 2 bytes where as an int in C/C++ is four under windows. So if you even going to convert, check first.
You should use Long variables instead of Integers. That way, you won''t need to convert them if you want to use them in C++.
Or the other way: use Integers in VB, but then use short int in C++.

This topic is closed to new replies.

Advertisement