View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Juan Pablo González Juan Pablo González is offline
external usenet poster
 
Posts: 226
Default Declaring As Variant, Changing to Double?

k wrote:
I'm working on a macro where an Application.Inputbox is used to have
the user enter a numerical value. When this variable is declared as
Double, everything works as expected. However, for the error-checking
code for the InputBox, it appears I need to use Variant as the value
of this variable (if the input is not entered properly) will not be a
numerical value in all cases. Multiple tests with varused as Variant
return an incorrect calculation.

Now, my question is as follows: is there a way to enter varused as a
Variant, but to convert it to a Double after I performed my
error-check for the Application.InputBox? I've included what I
believe is all applicable code, in the hopes it better illustrates my
problem. Any insight into why declaring varused As Variant causes my
code to malfunction would be an added bonues. ;-)

Thanks in advance for any assistance.

k

--


Have you tried using the CDbl() function ?

MyDouble = CDbl(MyVar)

--
Regards,

Juan Pablo González