Variants
-
Hello, I am a C#/VB programmer. I am trying to fix something that someone else wrote. There is a variable of type _variant_t. I need to take that value, and split it into 2 smaller variants. I am having problems doing this. If anyone can point me in the right direction, I would appreciate it. Here is the variable, "v", that I need to split into 2 variants. //-------------------------------------------------------- // "m_pResponseBuf->BufPtr()" is a pointer to the text in // a Response object. //-------------------------------------------------------- _variant_t v( m_pResponseBuf->BufPtr() ); m_Response->Write( v ); How would I take a portion of "v" and put the results into another variant? Thanks Danny
-
Hello, I am a C#/VB programmer. I am trying to fix something that someone else wrote. There is a variable of type _variant_t. I need to take that value, and split it into 2 smaller variants. I am having problems doing this. If anyone can point me in the right direction, I would appreciate it. Here is the variable, "v", that I need to split into 2 variants. //-------------------------------------------------------- // "m_pResponseBuf->BufPtr()" is a pointer to the text in // a Response object. //-------------------------------------------------------- _variant_t v( m_pResponseBuf->BufPtr() ); m_Response->Write( v ); How would I take a portion of "v" and put the results into another variant? Thanks Danny
A portion of v, from what you said, would then be a part of a string. To do string operations you can transfer the string into some more usable string object, do the operation you want then transfer the result into a variant. Usually a string contained in a variant is of type _bstr_t, so you can do: CString myString = (LPCTSTR)(_bstr_t)v; //Do operation on myString //Back into variant. _variant_t v2( (LPCTSTR)myString );
-
A portion of v, from what you said, would then be a part of a string. To do string operations you can transfer the string into some more usable string object, do the operation you want then transfer the result into a variant. Usually a string contained in a variant is of type _bstr_t, so you can do: CString myString = (LPCTSTR)(_bstr_t)v; //Do operation on myString //Back into variant. _variant_t v2( (LPCTSTR)myString );
Hello and thanks for the response. Is CString only for MFC apps? I read that somewhere. This dll I am working on is does not use MFC. I'll see if I can do something similar to this, which probably doesn't work, but I'll give it a shot. std::string myString = (_bstr_t)v; myString = myString.substr(0,1000); _variant_t v2( (_bstr_t)myString ); Thanks!!
-
Hello and thanks for the response. Is CString only for MFC apps? I read that somewhere. This dll I am working on is does not use MFC. I'll see if I can do something similar to this, which probably doesn't work, but I'll give it a shot. std::string myString = (_bstr_t)v; myString = myString.substr(0,1000); _variant_t v2( (_bstr_t)myString ); Thanks!!
-
Indeed my example was using MFC. Your example using std might work, but their might be a problem with the last operation: _variant_t v2( (_bstr_t)myString ); not sure you can typecast an std::string with _bstr_t.
Louis * google is your friend *
You're right. Didn't work. :( Thanks
-
You're right. Didn't work. :( Thanks
-
hint. myString.c_str() will return a "const char *". You can then assign that to the variant. _variant_t v2 (myString.c_str());
Louis * google is your friend *
You're right! I tried that, but I did it wrong. I used: _variant_t v2 (myString.c_str); Now it works with the parenthesis. Thanks!!!