|
Thanks for responce.I hava a biray type data in _variant_t.
_variant_t v1;
v1=(54 '6',53 '5',52 '4',54 '6',52 '4',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
Can i convert these values in CString or not.
Origal values is"65464".
Plz help me
|
|
|
|
|
What is v1.vt value?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
In VS2008, this should do the job...
_variant_t v;
CString s = v;
CString has assignment operator and constructor overl;oads that take a const VARIANT& . _variant_t has an extrractor that returns a VARIANT .
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
I (and Microsoft, who wrote the _variant_t and CString code) have helped you - you just assign the _variant_t to the CString - what more do you want?!?!?!?!?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
See what happen.
_variant_t vtValue;
vtValue = m_pRset->Fields->GetItem("Bianry")->GetValue();
CString b=vtValue;
output is b = "??4"
when i copy the vtValues at the time of debug then i got values
safearray of UI1 = [20](54 '6',53 '5',52 '4',54 '6',52 '4',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
Any more information if you nedd then i will give you.
|
|
|
|
|
As it's an array, VariantChangeType's not going to work. So, I'd suggest the code below.
I'm assuming you want to access the non-null characters of the array and make them into a string?
CComSafeArray<char, VT_UI1> sa(V_ARRAY(&v));
CString s;
for(int index=sa.GetLowerBound();index<=sa.GetUpperBound()&&sa[index];++index)
{
s+=sa[index];
}
[edit] You'll also need to #include atlsafe.h and oleauto.h [/edit]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart,
What do you think about this VT_UI1 SAFEARRAY to CStringA conversion method?
BSTR b;
BstrFromVector(pSA,&b);
CStringA s = (LPCSTR)b;
Best Wishes,
-David Delaune
|
|
|
|
|
New to me - that'll teach me to do what I've told many other people to do and read the documentation
And of course it'll work with wide CStrings as well.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
thanks it's working for me.
|
|
|
|
|
Hi rdop,
The following snippit will work on all Microsoft compilers:
_variant_t v;
v = 3.141;
::VariantChangeType(&v, &v, 0, VT_BSTR);
CString s = (LPTSTR)(_bstr_t)v.bstrVal;
Best Wishes,
-David Delaune
|
|
|
|
|
Hi vc++ programmers,
I am migrating my project from vs-2003 to vs-2008...I am getting bolow linking error when i am building my project.
errorfwstsrv.obj : error LNK2019: unresolved external symbol "public: int __thiscall DomIssuerInfo::HasSurvFeeBillableDebt(class DblDateTime const &,class ATL::CStringT<char,class StrTraitMFC_DLL<char,class ATL::ChTraitsCRT<char> > > const &)
I have set the linker settings.When i am saying project Settings->linker->General->Use library dependencies:YES,i am getting above error.. If i say NO i am getting the corresponding library also added with the above error.I have set all my libraries through linker settings...but notknow why i am getting....................please give some remeby to this.... thanks in advance........
|
|
|
|
|
CString changed between VS2003 and VS2008 - have the libraries been recompiled with VS2008?
Presuming you know which library that function should be defined in, you could use Dependency Walker to check if the library does actually export that function.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
HI Thankyou for your reply,I have recompiled again and again...my project is working in release mode.But when comes to debug mode it is giving linking errors(362) of the same type.....
And i have also tried to giv the library paths through #pragma comment(lib,"..."),,,but i am not exactly getting where should i include this pragma directive.....
can you further help?
modified on Tuesday, September 15, 2009 7:04 AM
|
|
|
|
|
OK - you sdee where you said 'I have set the linker settings.' in your first settings - you realise that Release and Debug modes have different settings?
Vetukuri Raju wrote: And i have also tried to giv the library paths through #pragma comment(lib,"...")
You can put it any where - I usually put the #pragma right after the #include that brings in that library's header file.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
No,,,i dinnt find any major differences.....out of 10 libraries it is anable to link three libraries...
My application is succesfully working on vs-2003....i have compared with 2003 debug setting also....
|
|
|
|
|
Ok,well i needed to write a program to display all alphabets,ie A to Z and i got a question(s) to ask.
The program i wrote is as follow :
#include<iostream>
using namespace std;
int main()
{
char letter='A';
while(letter<='Z')
{
cout<<letter;
letter++;
}
return 0;
}
1) The part where i bold-ed, why is there a need to put in the sign '...'?I tried running it without the '...' sign but the program won't run. It says its undeclared.
2)From (1),whats the difference if i put ".." instead of '...'?
3)If i were to declare something of type int,say "count=1".Why will the program run with count=1 and NOT run if i put count='1'.(see (4)where i put a '...' sign before and after the 0/26 after count)
4)If i were to modify my program into the following :
#include<iostream>
using namespace std;
int main()
{
char letter='A',count='0';
while(count<='26')
{
cout<<letter;
letter++;
count++;
}
return 0;
}
the whole program keeps running and i need to restart my laptop as the compiler somehow stuck. Why?
Thanks for answering.
|
|
|
|
|
UKM_Student wrote: he part where i bold-ed, why is there a need to put in the sign '...'?
Because that's (with one letter inside the quotes) the syntax for character constant s, see [^].
UKM_Student wrote: I tried running it without the '...' sign but the program won't run. It says its undeclared.
That's fine: without the quotes, A is no more a character constant , but instead an undeclared identifier .
UKM_Student wrote: 2)From (1),whats the difference if i put ".." instead of '...'?
Double quotes are used for string literals [^].
UKM_Student wrote: 3)If i were to declare something of type int,say "count=1".Why will the program run with count=1 and NOT run if i put count='1'.(see (4)where i put a '...' sign before and after the 0/26 after count)
The program will run in both cases, generating, of course, different outputs.
UKM_Student wrote: 4)If i were to modify my program into the following :
#include<iostream>
using namespace std;
int main()
{
char letter='A',count='0';
while(count<='26')
{
cout<<letter;
letter++;
count++;
}
return 0;
}<="" blockquote="">
Typing nearly random statements inside the IDE maybe amusing, I guess...
I strongly suggest you read a good C/C++ tutorial.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
What do u mean by IDE?
And regarding part 3, when i put count='1',the whole compiler runs it and gets stuck O_O,need to restart :X
|
|
|
|
|
UKM_Student wrote: What do u mean by IDE?
The same thing quite a lot of people mean too, I suppose [^].
(Should I say 'editor '?)
UKM_Student wrote: And regarding part 3, when i put count='1',the whole compiler runs it and gets stuck O_O,need to restart :X
The compiler runs and compiles the program. At the end you've an executable that, in turn, runs badly (make you restarting the computer). When a program hangs a system, it is, of course running, and producing (pretty noticeable) output.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Ok,thanks for your help.
|
|
|
|
|
UKM_Student wrote: The program i wrote...
Really?
UKM_Student wrote: 1) The part where i bold-ed, why is there a need to put in the sign '...'?
What sign?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
What do u mean by really?
I remembered asking that question before and someone helped me out in editing my "wrong" program but i forgot to ask why he needed to put that '...' sign, but anyway, through trial and error i managed to produce the following :
#include<iostream>
#include<string>
using namespace std;
int main()
{
char letter='A',count=1;
while(count<=26)
{
cout<<letter;
letter++;
count++;
}
return 0;
}
|
|
|
|
|
UKM_Student wrote: What do u mean by really?
I remembered asking that question before and someone helped me out in editing my "wrong" program...
It came from here.
UKM_Student wrote: i forgot to ask why he needed to put that '...' sign,
What is a '...' sign? Elipses are often used with code snippets to show missing, irrelevant code. How do they pertain to this thread?
UKM_Student wrote: ...through trial and error i managed to produce the following :
#include<iostream>
#include<string>
using namespace std;
int main()
{
char letter='A',count=1;
while(count<=26)
{
cout<<letter;
letter++;
count++;
}
return 0;
}<="" blockquote="">
What trial and error? The code I gave you worked fine. Why the introduction of count ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Ah so u were the person that helped me out the other day :P
The sign i was talking about isn't the '...',but rather the ' ' sign,ie, why should we put char='A' and not char=A.But palin helped in answering this part earlier already xD
Re:Trial and error part, my tutor said the program was too short, and moreover someone else in my class also used the same program so i tried introducing the count char and after a few tries, i managed to get the answer. :P
|
|
|
|
|