Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Differentiate b/w False and 0 with InputBox fn

I'm using an InputBox to get info from the user. I am getting 5 numbers and strings associated with a product. Some of the numbers can be zero. I would like to have the user be able to hit cancel anytime before entering in the 5th variable to cancel the whole operation. IE, put the old info back in and prompt the user to select a new product. This works fine unless they enter 0 for a number. Here is a snippet of the code: (note: the variables are Variants so that I can test for a FALSE return from InputBox. Seperate question: could my number variables be singles instead?) TI

'This is inside a larger Do..Loop that covers entering all five variables. All five variables have loops like this below to test the input from the user

D
vOldCost = .Cells(RowNum, 16).Value 'Capture the old Cost dat
vCost = Application.InputBox(prompt:="Enter material cost.",
Type:=1
If vCost = False Then 'problem is here...user enters in 0 for cost and the If gets executed
CancelProdInput vOldProduct, vOldCost,
vOldType, vOldTime, vOldPrice, RowNum ' CancelProdInput puts the 'Old' data back in the correct cell
GoTo LoopBegin 'go back to beginning....ask user to select product
End I
.Cells(RowNum, 16) = vCos
Loop Until vCost = 0
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Differentiate b/w False and 0 with InputBox fn

If always use

If TypeName(vCost) = "Boolean" Then
'It's False
End If

--
Regards

Juan Pablo González

"Marcotte A" wrote in message
...
I'm using an InputBox to get info from the user. I am getting 5 numbers

and strings associated with a product. Some of the numbers can be zero. I
would like to have the user be able to hit cancel anytime before entering in
the 5th variable to cancel the whole operation. IE, put the old info back
in and prompt the user to select a new product. This works fine unless they
enter 0 for a number. Here is a snippet of the code: (note: the variables
are Variants so that I can test for a FALSE return from InputBox. Seperate
question: could my number variables be singles instead?) TIA

'This is inside a larger Do..Loop that covers entering all five variables.

All five variables have loops like this below to test the input from the
user.

Do
vOldCost = .Cells(RowNum, 16).Value 'Capture the old Cost data
vCost = Application.InputBox(prompt:="Enter material cost.", _
Type:=1)
If vCost = False Then 'problem is here...user enters in 0 for cost

and the If gets executed.
CancelProdInput vOldProduct, vOldCost, _
vOldType, vOldTime, vOldPrice, RowNum '

CancelProdInput puts the 'Old' data back in the correct cells
GoTo LoopBegin 'go back to beginning....ask user to

select product
End If
.Cells(RowNum, 16) = vCost
Loop Until vCost = 0



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Differentiate b/w False and 0 with InputBox fn

Another solution (Juan Pablo is always a bit quicker...).

Change from:

If vCost = False

To:

If CStr(vCost) = "False"



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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Differentiate b/w False and 0 with InputBox fn

Cool, that seems to work.... thanks a lot.
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
How to differentiate groups of numbers RodJ Excel Worksheet Functions 6 September 25th 08 08:24 AM
How do I differentiate between duplicate ranks? Pez Excel Worksheet Functions 1 March 27th 06 12:12 AM
Differentiate between Number and Date? Merle Excel Discussion (Misc queries) 11 January 16th 06 08:46 AM
True Or False, no matter what... it still displays the false statement rocky640[_2_] Excel Programming 2 May 13th 04 04:57 PM
Differentiate between cell colours gav meredith Excel Programming 2 April 28th 04 05:06 AM


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