Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6722785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:29:20+00:00 2026-05-26T09:29:20+00:00

In a C++ DLL which is used from a legacy VB6 program, I use

  • 0

In a C++ DLL which is used from a legacy VB6 program, I use the CURRENCY data type to return some large values.

The code I’m using to fill it is this:

CURRENCY INT64toCURRENCY(INT64 int64) 
{
    CURRENCY ret;
    ret.int64 = int64 * 10000;
    return ret;
}

An integer overflow might arise here, but this is the least problem: The code doesn’t work for negative numbers, INT64toCURRENCY(-1) appears in VB6 as 4 294 967 295 which is 232–1.

However, cout << INT64toCURRENCY(-1).int64 shows –10000 which I suppose is correct.

The VB6 program is basically this:

Public Declare Function My_Fun Lib "My_Lib.dll" _
(ByVal param As Boolean) As Currency
Dim c As Currency
c = My_Fun(True)

and My_Fun is defined as

extern "C" CURRENCY __stdcall My_Fun(VARIANT_BOOL param)
{
    return INT64toCURRENCY(-1);
}

What’s the problem here and what is the correct code to convert a signed 64-bit integer to CURRENCY?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:29:21+00:00Added an answer on May 26, 2026 at 9:29 am

    VarCyFromI8 is the best solution.

    http://msdn.microsoft.com/en-us/library/ms644370(v=vs.85).aspx

    The CURRENCY type is a bit tricky with regards to signed values; just use what is already there rather than mess with it on your own.

    Note that the 64 bit variants are not technically supported until XP. Of course you could use the other VarCyFrom* functions, eg with a DECIMAL or an I4.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to create a DLL which is used by a VB6 application. This
I'm working on a DLL which will be used from another language (so no
I wrote a C++ DLL using VS 2010 which is used to wrap some
How do I determine which version of comctl32.dll is being used by a C#
We have inherited VB6 dll which we need to make changes to. We have
I have a .NET dll which needs to read it's config settings from it's
I have a DLL which contains a class with static members . I use
I have created a .NET DLL which makes some methods COM visible. One method
We have a DLL which provides the data layer for several of our projects.
I have an issue with a third-party COM+ DLL meant to be used from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.