View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Ivan F Moala[_3_] Ivan F Moala[_3_] is offline
external usenet poster
 
Posts: 38
Default Declaring As Variant, Changing to Double?

Try Rons suggestion

Dim varused As Variant

varused = Application.InputBox("Enter the value.", Type:=1)
'// User cancelled
If varused = False Then End
MsgBox varused

You should when ever possible try an intercept know return values
as early as possible, using the Type:=1 forces the input to accept
numbers only ie you have intercepted / masked out any Non numerics
out earlier on and don't need to test for this.

kkknie wrote in message ...
This is how I do it:


Code:
--------------------
Dim strTemp as String
Dim varused as double

strTemp = Application.InputBox("Enter the value.")

If Not IsNumeric(strTemp) Then
'Message non numeric and exit
End If

If Trim(strTemp) = "" Then
'Message blank and exit
End If

varused = CDbl(strTemp)
--------------------

K


---
Message posted from http://www.ExcelForum.com/