View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default figuring return type of a field

If instr(1,activecell.Text,":",vbTextcompare) then
' formatted in hours?
elseif Instr(1,activecell.text,".",vbTextcompare) then
' formatted in decimal?
else

end if

without knowing more about what you do when you convert and what you mean by
hours and decimal, it would be hard to tell what is the best approach.

By hours, you could mean a whole number. I assumed you meant stored as a
time serial number and formatted as time. In lieu of the hardcoded
Comma/colon, you might want to use the internation function as demo'd from
the immediate window (I have US English settings).

? application.International(xlDecimalSeparator)
..
? application.International(xlTimeSeparator)
:

--
Regards,
Tom Ogilvy



" wrote:

I have posted this on excel, didn't get any help. Thought I should try
here.

My goal is to find the return type of a field. I have created a
customized right click menu. A user can right click and then choose
"conversion" option to convert the cell value, either from hours to
decimal or from decimal to hours. It is working fine.
The problem is: the program should be able to find out the difference
between hours and decimal value. To my understanding, the program
takes the value as "double" irrespective of the value in hours or
decimals.
Can I get some help here in figuring out the hour type ? I want to
display the alert message if the user try to convert hours to hour or
decimal to decimal. I can only do that if I can find out the cell
value in hours and decimals independently.
Thanks in advance,