Serving the Quantitative Finance Community

 
User avatar
futurenets
Topic Author
Posts: 0
Joined: October 12th, 2002, 3:25 pm

VB to VC automation

November 5th, 2002, 12:47 pm

I'm using the VB-toVC automation code converter to help me create a dll function that places some text into an excel spreadsheet cell.If I want to send "YES" then it produces: rVal.vt = VT_BSTR;rVal.bstrVal = ::SysAllocString(L"YES");VariantCopy(&xlvalue, &rVal);VariantClear(&rVal);does anyone now how I can specify a variable name in ::SysAllocString instead of "YES"e.g. something like ::SysAllocString(L str);Thanks PW
 
User avatar
jens
Posts: 0
Joined: July 14th, 2002, 3:00 am

VB to VC automation

November 5th, 2002, 1:06 pm

std::wstring str(L"string I want to pass");...rVal.vt = VT_BSTR;rVal.bstrVal = ::SysAllocString(str);The L prefix tells the compiler that this is a wide/unicode string constant. If you have a char* try the USES_CONVERSION and A2OLE macros.Jens.
Last edited by jens on November 4th, 2002, 11:00 pm, edited 1 time in total.
 
User avatar
futurenets
Topic Author
Posts: 0
Joined: October 12th, 2002, 3:25 pm

VB to VC automation

November 6th, 2002, 9:59 am

thanks Jens, your help was invaluable.I was using char * and the following worked fine:USES_CONVERSION;rVal.vt = VT_BSTR;rVal.bstrVal = ::SysAllocString(A2OLE(strptr));VariantCopy(&xlvalue, &rVal);VariantClear(&rVal);RegardsPW