Problem w. VB Len on VARIANT_BOOL 
Author Message
 Problem w. VB Len on VARIANT_BOOL


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


(here's the get and put):
        _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;


        MSXML2::IXMLDOMNodePtr pTemp =
m_oXml.findNodeAddIfAbsent(m_NodeBody, "New",

        try  {
                pTemp->text = (newVal =
true) ? "True" : "False";
        catch(...)  {
                Error("Error setting New.");
                return E_FAIL;
        return S_OK;


Sat, 11 Sep 2004 03:12:43 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Can't get Len of long, VARIANT_BOOL in vb client

2. Working with VARIANT_BOOL

3. VARIANT_BOOL* error

4. Novice: Return Value VARIANT_BOOL?

5. Len

6. int gethostname(char FAR* name, int len)

7. register char str[LEN]

8. File len and drives

9. Storing vari-len strings

10. VARIANT, VARIANT_BOOL, and VB Boolean - how is this done?

11. VB and VC or VB and VB

12. Reference problem when using VB classes with C# classes


Powered by phpBB® Forum Software