conversion to _bstr_t - newbie
-
_bstr_t is a type which can hold unicode string. CString strText; // format the value to CString strText.Format("%d",nValue); call strText.AllocSysString(); to convert SaRath.
"Don't Do Different things... Do Things Differently..."SaRath C wrote:
_bstr_t is a type which can hold unicode string.
you getting very fast :)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
Thanks ThatsAlok I'm getting there is almost working how about doubles? Appreciate the help
-
Thanks ThatsAlok I'm getting there is almost working how about doubles? Appreciate the help
antonaras wrote:
how about doubles?
use %e format
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Re
-
_bstr_t is a type which can hold unicode string. CString strText; // format the value to CString strText.Format("%d",nValue); call strText.AllocSysString(); to convert SaRath.
"Don't Do Different things... Do Things Differently..."SaRath C wrote:
call strText.AllocSysString(); to convert
there can Memory Leak problem here!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You
-
antonaras wrote:
how about doubles?
use %e format
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Re
Hey ThatsAlok i tried your code and it works fine with integers but i have double valField4; TCHAR szStr2[100]; wsprintf(szStr2,"%e",valField4); _bstr_t bstText2(szStr2); printf("%s\n",(LPCSTR)bstText2); the otput for bstText2 that i get is e why does that happen thanks again
-
Hi guys can i convert integers and doubles to _bstr_t; if yes can you tell me how thanks a lot
If you are familiar with STL, you can use one more method:
int i = 1234567; double d = 123.4567; _bstr_t s1, s2; // convert integer { std::ostrstream os; os << i << std::ends; s1 = os.str(); } // convert double { std::ostrstream os; os << d << std::ends; s2 = os.str(); }
-
If you are familiar with STL, you can use one more method:
int i = 1234567; double d = 123.4567; _bstr_t s1, s2; // convert integer { std::ostrstream os; os << i << std::ends; s1 = os.str(); } // convert double { std::ostrstream os; os << d << std::ends; s2 = os.str(); }
Thanks Viorel i tried your code but i get lots of compilation errors 'ostrstream' : undeclared identifier syntax error : missing ';' before identifier 'os' 'os' : undeclared identifier and so on what i'm doing wrong i have included string is there anything else i need to include thanks
-
Thanks Viorel i tried your code but i get lots of compilation errors 'ostrstream' : undeclared identifier syntax error : missing ';' before identifier 'os' 'os' : undeclared identifier and so on what i'm doing wrong i have included string is there anything else i need to include thanks
In order to use these STL features, you have to include a header file:
#include <strstream>
Next, you may receive an "unresolved external symbol" error displayed by the linker. In this case, you have to make one more addition: specify "comsuppwd.lib" in the "Linker --> Input --> Additional Dependencies" configuration option of your project. (In release compilation mode, specify "comsuppw.lib"). You can always see which header file or library is required by analyzing the descriptions in MSDN.
-
In order to use these STL features, you have to include a header file:
#include <strstream>
Next, you may receive an "unresolved external symbol" error displayed by the linker. In this case, you have to make one more addition: specify "comsuppwd.lib" in the "Linker --> Input --> Additional Dependencies" configuration option of your project. (In release compilation mode, specify "comsuppw.lib"). You can always see which header file or library is required by analyzing the descriptions in MSDN.
-
Hi guys can i convert integers and doubles to _bstr_t; if yes can you tell me how thanks a lot
antonaras wrote:
can i convert integers and doubles to _bstr_t;
Just assign them:
double d;
int x;
_bstr_t str;
str = d;
str = (long) x;
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb