473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

The missing C++ unsigned short integer in VB6

C++ has a variable type 'unsigned short int.' I am trying to write a VB6
program that prints these out of a file made originally by C++. However,
the unsigned short integer (1-65535) is not supported. Does anyone have a
routine that will allow VB6 to read a C++ unsigned short int?

Thanks

Del
Jul 17 '05 #1
2 11140
you could read two single bytes from the file and use a function like:

Public Function MakeWord(msb As Byte, lsb As Byte) As Long
MakeWord = CLng("&h" & Trim$(Hex(msb)) & Trim(Hex(lsb)))
End Function

Function takes two bytes and makes a C++ short integer(word) 16bit
msb;Most significan byte, lsb;least signinficant byte, watch the byte order.

VB does not support Unsigned data type so must return a long

probably not the most efficient inplementation but serves as an example

hope it helps, any probs....
al.

"Salgoud Dell" <sa*****@nomail.com> wrote in message
news:<ca**********@news.cfu.net>...
C++ has a variable type 'unsigned short int.' I am trying to write a VB6
program that prints these out of a file made originally by C++. However,
the unsigned short integer (1-65535) is not supported. Does anyone have a
routine that will allow VB6 to read a C++ unsigned short int?

Thanks

Del

Jul 17 '05 #2
"Salgoud Dell" <sa*****@nomail.com> wrote in message news:<ca**********@news.cfu.net>...
C++ has a variable type 'unsigned short int.' I am trying to write a VB6
program that prints these out of a file made originally by C++. However,
the unsigned short integer (1-65535) is not supported. Does anyone have a
routine that will allow VB6 to read a C++ unsigned short int?


VB6 can read it into an Integer variable just fine. Values 32768 to
65535 will be displayed as -32768 to -1 but you can either just use
them that way or move the values to a Long and mask off the low 16
bits to see the original values.
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
by: Andy | last post by:
Hi, Are 1 through 4 defined behaviors in C? unsigned short i; unsigned long li; /* 32-bit wide */ 1. i = 65535 + 3; 2. i = 1 - 3; 3. li = (unsigned long)0xFFFFFFFF + 3; 4. li = 1...
10
by: Vijay Kumar R Zanvar | last post by:
Hi clc, Please elaborate the warning: F:\Vijay\C> type unsigned2.c #include <stdio.h> #include <stdlib.h> int
8
by: avsrk | last post by:
Hello Folks , General C data types question , more geared up towards embedded folks . I have a positive float quantity with a fractional part (one decimal point) which occupies 4 bytes ....
4
by: slougheed | last post by:
I encountered a problem after we had converted our declarations of 'unsigned short int' to uint16_t. In one instance, whoever did the conversion failed to delete the 'short' keyword so we had a...
5
by: wolverine | last post by:
Hi I want to know how to use basic_string with unsigned short (I have mentioned below why i have to do this). Could any tell me some good references in this topic. I am new to creating a new...
0
by: wolverine | last post by:
Hi I want to know how to use basic_string with unsigned short (I have mentioned below why i have to do this). Could any tell me some good references in this topic. I am new to creating a new...
1
by: wolverine | last post by:
Hi, Given below is a traits with unsigned short. If i create a stringstream with this traits will there be any problem. struct XMLCh_traits { typedef unsigned short char_type; typedef...
10
by: Jim Langston | last post by:
Is the following well defined? size_t IntVal = 65537; unsigned short Length; if ( IntVal static_cast<unsigned short>( -1 ) ) { std::cout << "Value too long to fit in a short" << std::endl;...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.