Jump to content
  • Advertisement
Sign in to follow this  
Evil Steve

VBA: Swap Endian

This topic is 3695 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

Hi all, I'm trying to modify an Excel macro in VBA which generates binary files to output in big-endian (for Wii), however I'm not very experienced with VB / VBA, and Googling doesn't really give me much luck. I need to convert Integers (16-bit values) and Longs (32-bit values) into big endian, or at least output them byte swapped. I tried doing some bit shifting and masking as I would in C++, using This Code for shifting, but I keep getting overflow errors when I Or the bytes together. So, my question is; is there a straightforward way to byte-swap Integer's and Long's for outputting to a file and if not, is there a way to use unsigned Integers and Longs to avoid these overflow errors? Cheers, Steve

Share this post


Link to post
Share on other sites
Advertisement
The easiest way is probably just to dllimport htonl() and htons() from Winsock and call those. (Assuming you're running on a little endian machine anyways.)

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
The easiest way is probably just to dllimport htonl() and htons() from Winsock and call those. (Assuming you're running on a little endian machine anyways.)
Ah, excellent - never thought of that, thanks [smile]

And yeah, I'm running on XP Pro (Little endian)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!