VB string variable problem

Posted on 2011-05-04
Last Modified: 2012-05-11
I am receiving information from a C++ dll in VB

the info comes in BSTR strings.. I am receiving 5 variables at once.. everything is the same for all of them

except for 1 of them for some reason its receiving tons of jibberish after the info.. why is that?

when I Msgbox this string variable in VB it only shows the real info.. but when I output it to a log file it shows the jibberish

Here is an example... (Fun) is the real info.. the rest is the jibberish that is added

Question by:bail3yz
    LVL 74

    Accepted Solution

    Perhaps the string is not being properly null-terminated in the c++ DLL?

    Author Comment

    Heres the system

    C++ dll gets info (I dont have full source to this dll) and sends it another C++ dll (i have source) .. this dll sends it to VB

    middle dll code is show below

    vbFunc2 is a callback function for VB

    I do have the code for when tr->name gets filled.. and it looks fine to me.. but I am not very good in C++
    I compared it to the other variables that are working good and everything seems the same

    HANDLE GetRC(TClientPlayerRecord * tr)
            CString stringTemp(tempPlayer);
    	BSTR temp = stringTemp.AllocSysString(); 
    	return 0;

    Open in new window


    Author Comment

    Also in VB when I get the length of the variable.. it returns the answer discluding the jibberish

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now