473,325 Members | 2,870 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,325 software developers and data experts.

Data Type VC++ <--> VB6

Hi All, I have a problem. I have written a COM DLL in VB6 to do some
stuff. I need to call this DLL from a VC++ program for which I have the
code. I have managed to get as far as creating the instance of the COM
object and calling a method from within the C++ program - not being a
C++ programmer at all, this was a huge undertaking, and I'm very proud
of myself for even getting this far ;-).

My Question is in relation to passing parameters from the C++ program
to my VB COM Object. If I define a String variable in VB, what must my
parameter in C++ be in order for it to talk properly. There seems to be
a whole host of string types available - CHAR, CString, LPCOLESTR,
OLESTR, TCHAR, blah, blah, blah, and each of these types are only
applicable for specific things. Maybe I have it wrong, if so, please
correct me. Number data is also a headache. If someone could explain to
me the correlation from C++ to VB, maybe even provide a list of C++ to
VB data type equivalents, I would be most appreciative.

Many Thanks Rob

Jul 22 '05 #1
3 3196
> Hi All, I have a problem. I have written a COM DLL in VB6 to do some
stuff. I need to call this DLL from a VC++ program for which I have the
code. I have managed to get as far as creating the instance of the COM
object and calling a method from within the C++ program - not being a
C++ programmer at all, this was a huge undertaking, and I'm very proud
of myself for even getting this far ;-).

My Question is in relation to passing parameters from the C++ program
to my VB COM Object. If I define a String variable in VB, what must my
parameter in C++ be in order for it to talk properly. There seems to be
a whole host of string types available - CHAR, CString, LPCOLESTR,
OLESTR, TCHAR, blah, blah, blah, and each of these types are only
applicable for specific things. Maybe I have it wrong, if so, please
correct me. Number data is also a headache. If someone could explain to
me the correlation from C++ to VB, maybe even provide a list of C++ to
VB data type equivalents, I would be most appreciative.

Many Thanks Rob


A BSTR in C++ corresponds to the VB String.

BSTR Manipulation Functions Descriptions
SysAllocString Creates and initializes a string.
SysAllocStringByteLen Creates a zero-terminated string of a specified length
(32-bit only).
SysAllocStringLen Creates a string of a specified length.
SysFreeString Frees a previously created string.
SysReAllocString Changes the size and value of a string.
SysReAllocStringLen Changes the size of an existing string.
SysStringByteLen Returns the length of a string in bytes (32-bit
only).
SysStringLen Returns the length of a string.

_bstr_t is a VC++ wrapper for BSTR. The Active Template Library wrapper is
CComBSTR.

Jul 22 '05 #2
On 4 Jan 2005 01:46:18 -0800, ro****@mindkey.co.za wrote:
Hi All, I have a problem. I have written a COM DLL in VB6 to do some
stuff. I need to call this DLL from a VC++ program for which I have the
code.


Not many people here know how to interact with the windows API.

http://www.slack.net/~shiva/welcome.txt
news:comp.os.ms-windows.programmer.win32

<ot>
As the other poster mentioned, the desired datatype is BSTR. You can find
the other appropriate datatypes under the "IDispatch Data Types and
Structures" section in the MSDN help file.
</ot>
Jul 22 '05 #3
Thanks guys, that helped. Not sure what it means, but I had a problem
when My BSTR parameters (3 of them), were positioned after my numeric
parameters (2 doubles, 1 __int64). They were coming through as blank on
the vb side. Switching them around so that I have the BSTR params
first, then all the numerics. Wierd ?, dunno, but at least it's working
now. Cheers

Jul 22 '05 #4

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

Similar topics

21
by: Batista, Facundo | last post by:
Here I send it. Suggestions and all kinds of recomendations are more than welcomed. If it all goes ok, it'll be a PEP when I finish writing/modifying the code. Thank you. .. Facundo
1
by: Geoff Biggs | last post by:
Evening all, I'm trying to add a new built-in number data type to Python with its own syntax, so I'm working directly with the interpreter rather than creating my own extension module (side...
5
by: Eternally | last post by:
Hey folks, To me, this sounds like a crazy question, but I'll throw it out there anyway. Is it possible to change a variables data type half way through a running program? If so, how? ...
13
by: dawatson833 | last post by:
I have several stored procedures with parameters that are defined with user defined data types. The time it takes to run the procedures can take 10 - 50 seconds depending on the procedure. If I...
13
by: Peter | last post by:
Can anyone tell me how to change the data type of a field in a table created with a make table query? The field is a binary and must be changed to text. alternately does anyone know how to specify...
6
by: Mike Hoff | last post by:
I am trying to write a class that will store info about database fields for building UPDATE / INSERT commands later on. I cannot seem to get the sytax correct to pass and store the data type of...
2
by: x | last post by:
hi i am a pilot by profession. i want to create a database of my logbook using ms access 2002. i am facing a problem regarding the format of time field. when i select "Data/Time" data type for my...
13
by: Fei Liu | last post by:
Hi Group, I've got a problem I couldn't find a good solution. I am working with scientific data files in netCDF format. One of the properties of netCDF data is that the actual type of data is only...
2
by: rohit deshpande | last post by:
Hi, i am learning VC++, i am inputting some text from edit box of dialog box to a CString variable. now i want to convert it to char data type. i don't know how.....????? plzz help
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.