return type of a field

N

Nasir

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,
 
B

Bob Phillips

Try something like this

Select Case TypeName(Val)
Case "Integer": MsgBox "Integer"
Case "Double": MsgBox "Double"
End Select

where Val is a variant variable.

--
HTH

Bob Phillips

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
N

Nasir

Perhaps I didn't explain well in my previous post.
The problem: suppose we have a cell value as "175:12" the answer in
decimal would be "175.2". However, if I try to convert(wrongly) from
hours value to hours then I should be able to display the alert
message as "value is in hours already, please choose a decimal value".
Same should happen for an attempt to convert decimal to decimal. For
example, converting "175.2" to hours should display "175:12". However,
if by mistake the user click convert to decimal for a decimal value,
then there should be the alert message as "value in decimal already,
please choose an hour value".
TypeName() returns "double" for both hours and decimal. I was
wondering, if I could get the return type as hours or some different
return type for decimal and hours, then I could perhaps use that in an
"if-else" block to do the needful.
I am hoping to get some help in this regard, thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top