View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
witek witek is offline
external usenet poster
 
Posts: 147
Default XLL, C++ and dates

joel wrote:
A date is just a number and is passed between functions as a single
variable type. Microsoft treat numbers and dates exactly the same
except at the user interface they are displayed differently. There arre
a few quirks in excel the microsoft screws up the number by trying to be
too smart and looses accuracy of the number. I sometimes havve to
declare a variable in VBA as a single instead of a date so the built in
VBA functions don't do things I don't want them to do.


You can sue the Wind32 functions to convert your string dates to
number. See this URL for a list of functions.


'National Language Support Functions (Windows)'
(http://msdn.microsoft.com/en-us/libr...81(VS.85).aspx)


I can write VBA functions that can call any of these functions. In C++
there are usually header funtions in the C++ libraries that can also
call these Win32 DLLs. I haven't written a lot of C++ code to know
exactly how to use these functions but if figure out which function(s)
you want to use then do a search on the web for sample code.



1.Excel does not follow standard which is used in VBA, so VBA date and
Excel date are not the same.

2. I do not have strings. I have a number: 42345. And I need to know
year, month and day.

3. I also need to know if 42345 was entered by user as 42345 or as a
date which is represented by that number.

#2 is easy, but requires a little bit of thinking :)
I expected, that maybe Microsoft did that thinking for me.

#3 is not easy and I do not know an answer.