Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overflow error when call Ubound method

Status
Not open for further replies.

wallaceoc80

Programmer
Jul 7, 2004
182
0
0
GB
Hi, I am getting an "Overflow" error when I call Ubound on an object of type Variant
Code:
numResult = UBound(result)

I have tried doing some searching on the net and I can't figure this one out. Has anyone ever encountered this before? The result object looks to be ok when I check it in debug mode.

Thanks,
Wallace
 
Some more info that might help. result object is a class that I have created as follows:
Code:
class HedgeResult
    {
        friend std::ostream & operator<<(std::ostream &, const HResult &);

    public:
        void clear();

        struct Result
        {
            std::string resultError;
            std::string ise;
            std::string desc;
            double position;
            double stub;
            double dve;
            std::vector<double> hr;
        };

        std::string globalError;
        std::vector<std::string> fNames_;
        std::vector<double> fPrs_;
        std::vector<std::string> fDates_;
        std::vector<Result> results_;
    };

By it looks OK I mean that the results_ vector in the struct has 774 items when I looked at it in debug mode and all the other members of the struct are set OK.

Does this help?

Thanks,
Wallace
 
From the VB code, it looks like you are anticipating an SAFEARRAY to be returned as the default mathod of your class. On the other hand there is nothing in your C++ code to suggest that this is the case ...
 
I figured out what was happening. Ubound returns a long and I was assigning the returned value to an Integer. This was ok some of the time but when a larger number was returned it caused the overflow.

Thanks for your suggestions.

Wallace
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top