CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: BSTR

  1. #1
    Join Date
    May 1999
    Posts
    1

    BSTR

    I need to how I can create a string which cat' various data to gether and then pass the variable to a BSTR.
    e.g.
    BSTR name= Information;
    LPSTR test=information;
    int i=10
    sprintf(test,"the value is %i",i);

    BSTR=SysAllocString(test);

    This does not work. How can I make it work?


  2. #2
    Join Date
    May 1999
    Posts
    42

    Re: BSTR

    Here's one way:

    #include "afxpriv.h"

    LPSTR information = "The value is ";
    int i = 10;
    CString test(information);
    char pIToA[4];
    itoa( i, pIToA, 10);
    test += pIToA;
    USES_CONVERSION;
    BSTR Information = A2BSTR( test.GetBuffer(2));



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured