Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2002 and VB declaring number as double Gary Excel Discussion (Misc queries) 2 March 5th 09 03:43 AM
How do I assign range to variant and use Mike H[_2_] Excel Discussion (Misc queries) 7 June 7th 07 01:40 AM
Testing if Variant is Range or Double? Don Wiss Excel Programming 3 January 26th 04 12:35 AM
Variant to String Chip Pearson Excel Programming 1 September 3rd 03 03:10 PM
DLLs and VBA: Who free's a variant? Keith Willshaw Excel Programming 0 August 6th 03 09:42 AM


All times are GMT +1. The time now is 04:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"