Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass a chr(0) to Visual Basic

Status
Not open for further replies.

foufoujr

Programmer
Aug 3, 2001
3
US
Hello,

How can a c++ method pass a string with some null characters (chr(0)) to a Visual Basic application. When i use a CString variable, the string i want to send to VB is cutted at the chr(0) character.

Thanks a lot

Jean-Rémy
 
Have you tried to pas a:
#define nullString \x00
- you can pass other character instead (printable or not printable)- and convert it hten in VB
- or you could shift your characters chrs few position to the right and do the reverse way in VB.

Anyway the target String from VB you should first alloc with
Dim MyString$
MyString = Space$(Len(MyString))


Hope this helps,
s-)

Blessed is he who in the name of justice and good will, shepards the week through the valley of darkness...
 
The VB application is an ocx and i can't add codelines in this vb application. In fact, the program ran well with C 16 bits and VB3 but since all was migrated in Visual C++ 5 and VB6, the strings with null charcaters are cutted.
 
Oh, you can pass to VB only BSTR. They have in a character two bytes instead of one. So one character is unsigned short, and the string will be unsigned short* or wchar_t*, or BSTR.
wchar_t* bstring = L"HELLO";//pay attention on L
char* cstring = "hello"; John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top