ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   #VALUE error in Excel using Visual C++ DLL (https://www.excelbanter.com/excel-programming/330430-value-error-excel-using-visual-c-dll.html)

[email protected]

#VALUE error in Excel using Visual C++ DLL
 
Hi,
I am getting a #VALUE error in Excel when I try to access the following
simple GetTime function via =get_c_system_time(NOW()). Can anyone
shed some light please.
Regards,
Chris Adams

(Apologies if its long - I thought maybe its the best way of
illustrating the problem.)


My VC code:
===========

#include <windows.h
#include <time.h

#define SECS_PER_DAY (24*60*60)

//================================================== ==============
// Returns the time of day rounded down to the nearest second as
// number of seconds since the start of the day
//================================================== ==============
long current_system_time(void)
{
time_t time_t_T;
struct tm tm_T;

time(&time_t_T);
tm_T = *localtime(&time_t_T);

return tm_T.tm_sec + 60*(tm_T.tm_min + 24* tm_T.tm_hour);
}
//================================================== ==============
// Returns the time of day rounded down to the nearest second as a
// fraction of 1 day, ie. compatible with Excel time formatting.
//
// Wraps the function long current_system_time(void) providing a
// trigger for Excel using the standard calling convention for
// Win32 DLLs.
//================================================== ==============
double _stdcall get_system_time_C(long trigger)
{
return current_system_time() / (double) SECS_PER_DAY;
}



My Excel Code:
==============

Declare Function get_system_time_C Lib "GetTime.dll" _
(ByVal trigger As Long) As Double

Function Get_C_System_Time(trigger As Double) As Double
Get_C_System_Time = get_system_time_C(0)
End Function



All times are GMT +1. The time now is 05:17 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com