Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Application.InputBox with Default:=0 testing False

Hi,

I am looking for help with the Application.InputBox in Excel. I want t
force the user to enter a number which default is 0. However I also wan
to check if the user press 'Cancel'. So my current code is somethin
like:

Temp = Application.InputBox("Input number:", "Input", 0, , , , , 1)
If Temp = False Then
Exit Sub
Else
'other code'
End If

However if I just hit 'Enter' with the default value, or enters '0' an
then 'Enter', my test ends the sub despite that a valid number (0) wa
entered. How do I avoid this conflict between the InputBox returnin
False on 'Cancel' and a value of '0' being read as False in the test?

Cheers

Bluhme

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Application.InputBox with Default:=0 testing False

Bluhme,
Unless anyone has a better way:

Temp = CStr(Temp)
If IsNumeric(Temp) Then

NickHK

"bluhme " wrote in message
...
Hi,

I am looking for help with the Application.InputBox in Excel. I want to
force the user to enter a number which default is 0. However I also want
to check if the user press 'Cancel'. So my current code is something
like:

Temp = Application.InputBox("Input number:", "Input", 0, , , , , 1)
If Temp = False Then
Exit Sub
Else
'other code'
End If

However if I just hit 'Enter' with the default value, or enters '0' and
then 'Enter', my test ends the sub despite that a valid number (0) was
entered. How do I avoid this conflict between the InputBox returning
False on 'Cancel' and a value of '0' being read as False in the test?

Cheers

Bluhme.


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Application.InputBox with Default:=0 testing False

Sub test()
Dim var As Variant

var = Application.InputBox("Input number:", "Input", 0, , , , , 1)
If VarType(var) = vbBoolean Then Exit Sub

MsgBox var
End Sub


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"bluhme " wrote in message
...
Hi,

I am looking for help with the Application.InputBox in Excel. I want to
force the user to enter a number which default is 0. However I also want
to check if the user press 'Cancel'. So my current code is something
like:

Temp = Application.InputBox("Input number:", "Input", 0, , , , , 1)
If Temp = False Then
Exit Sub
Else
'other code'
End If

However if I just hit 'Enter' with the default value, or enters '0' and
then 'Enter', my test ends the sub despite that a valid number (0) was
entered. How do I avoid this conflict between the InputBox returning
False on 'Cancel' and a value of '0' being read as False in the test?

Cheers

Bluhme.


---
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
Automation Testing in an Excel application. HC Excel Discussion (Misc queries) 0 March 30th 05 02:05 AM
Differentiate b/w False and 0 with InputBox fn Marcotte A[_2_] Excel Programming 3 June 8th 04 05:10 PM
Excel VBA - InputBox DEFAULT Value? BruceAtkinson[_3_] Excel Programming 3 May 26th 04 08:18 PM
application.inputbox Murat Excel Programming 4 February 24th 04 11:38 AM
Application.Inputbox Question ndp Excel Programming 3 December 8th 03 06:12 PM


All times are GMT +1. The time now is 12:05 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"