
Problem w. VB Len on VARIANT_BOOL
Hello,
I am getting the following error when I try to use the
intrinsic VB Len function on a boolean property I have in
an ATL server:
Variable required - can't assign to this expression.
The error comes when I try to run some code like this:
MsgBox Len(m_oClaimForm.Customer.New)
"New" is the offending property. If I do this:
MsgBox m_oClaimForm.Customer.New
I'll get True or False.
This is the IDL:
[propget, id(3), helpstring("property New")] HRESULT New
([out, retval] VARIANT_BOOL *pVal);
[propput, id(3), helpstring("property New")] HRESULT New
([in] VARIANT_BOOL newVal);
and the get and put are below. (I'm storing as xml
internally ... it's sort of a state management object for
asp pages.) The same thing happens when I try to use Len
on another property of mine that's a long data type. If I
do an explicit conversion in the client, it works ok:
MsgBox Len(CStr(m_oClaimForm.Customer.New))
It appears I need to return the expected data type (in
this case, a string. Can someone steer me in the right
direction?
TIA,
Paul
(here's the get and put):
STDMETHODIMP CCustomer::get_New(VARIANT_BOOL *pVal)
{
_bstr_t sVal;
sVal.operator = (m_oXml.findNodeText
(m_NodeBody, "New"));
try {
if (sVal.operator == ("True")) {
*pVal = true;
}
else {
*pVal = false;
}
}
catch(...) {
Error("Error getting New.");
return E_FAIL;
}
return S_OK;
Quote:
}
STDMETHODIMP CCustomer::put_New(VARIANT_BOOL newVal)
{
MSXML2::IXMLDOMNodePtr pTemp =
m_oXml.findNodeAddIfAbsent(m_NodeBody, "New",
NODE_ELEMENT);
try {
pTemp->text = (newVal =
true) ? "True" : "False";
m_NodeBody->appendChild(pTemp);
}
catch(...) {
Error("Error setting New.");
return E_FAIL;
}
return S_OK;
Quote:
}