Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Differentiate between False and Zero for Input Box return?

Hi Everyone,

I've got an input box that asks a question and I have the default set for
zero. I'd like to write some follow up logic that reverts back to the
beginning if the cancel button is chosen, but I'd like to keep the zero value
as true. Is there anyway to do this? I've included the code below. As always
I really appreciate the help.

Dim Sulfur As String
Sulfur = Application.InputBox("If you do not have any of this isotope in
your lab, please enter 0 and press OK", "35S", 0)
Range("G33") = Sulfur
If Sulfur = False Then
MsgBox "You clicked Cancel. Please try again.", 64, "Cancel was
clicked."
GoTo Sulfur
ElseIf Sulfur = 0 Then
GoTo P32
Else
GoTo P32
End If


Thanks,
Chad
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Differentiate between False and Zero for Input Box return?

Sub test()
Dim vResult As Variant

vResult = Application.InputBox("input or cancel")
If VarType(vResult) = vbBoolean Then
MsgBox "user cancelled"
Else: MsgBox vResult
End If

End Sub

Regards,
Peter T

"Chadersmith" wrote in message
...
Hi Everyone,

I've got an input box that asks a question and I have the default set for
zero. I'd like to write some follow up logic that reverts back to the
beginning if the cancel button is chosen, but I'd like to keep the zero
value
as true. Is there anyway to do this? I've included the code below. As
always
I really appreciate the help.

Dim Sulfur As String
Sulfur = Application.InputBox("If you do not have any of this isotope
in
your lab, please enter 0 and press OK", "35S", 0)
Range("G33") = Sulfur
If Sulfur = False Then
MsgBox "You clicked Cancel. Please try again.", 64, "Cancel was
clicked."
GoTo Sulfur
ElseIf Sulfur = 0 Then
GoTo P32
Else
GoTo P32
End If


Thanks,
Chad



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Differentiate between False and Zero for Input Box return?

Thanks Peter!

"Peter T" wrote:

Sub test()
Dim vResult As Variant

vResult = Application.InputBox("input or cancel")
If VarType(vResult) = vbBoolean Then
MsgBox "user cancelled"
Else: MsgBox vResult
End If

End Sub

Regards,
Peter T

"Chadersmith" wrote in message
...
Hi Everyone,

I've got an input box that asks a question and I have the default set for
zero. I'd like to write some follow up logic that reverts back to the
beginning if the cancel button is chosen, but I'd like to keep the zero
value
as true. Is there anyway to do this? I've included the code below. As
always
I really appreciate the help.

Dim Sulfur As String
Sulfur = Application.InputBox("If you do not have any of this isotope
in
your lab, please enter 0 and press OK", "35S", 0)
Range("G33") = Sulfur
If Sulfur = False Then
MsgBox "You clicked Cancel. Please try again.", 64, "Cancel was
clicked."
GoTo Sulfur
ElseIf Sulfur = 0 Then
GoTo P32
Else
GoTo P32
End If


Thanks,
Chad



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Differentiate between False and Zero for Input Box return?


Try

Dim S As String
S = InputBox("prompt", "title", 0)
If StrPtr(S) = 0 Then
Debug.Print "cancel"
Else
Debug.Print S
End If

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]





On Mon, 25 Jan 2010 09:21:02 -0800, Chadersmith
wrote:

Hi Everyone,

I've got an input box that asks a question and I have the default set for
zero. I'd like to write some follow up logic that reverts back to the
beginning if the cancel button is chosen, but I'd like to keep the zero value
as true. Is there anyway to do this? I've included the code below. As always
I really appreciate the help.

Dim Sulfur As String
Sulfur = Application.InputBox("If you do not have any of this isotope in
your lab, please enter 0 and press OK", "35S", 0)
Range("G33") = Sulfur
If Sulfur = False Then
MsgBox "You clicked Cancel. Please try again.", 64, "Cancel was
clicked."
GoTo Sulfur
ElseIf Sulfur = 0 Then
GoTo P32
Else
GoTo P32
End If


Thanks,
Chad

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
Conditional Formatting to differentiate between Input and Calcs Ditch Setting up and Configuration of Excel 3 February 5th 08 12:45 AM
Input box doesn't close if input is false Tsunami3169 Excel Programming 2 May 8th 07 04:58 PM
LOOKUP and return the column heading for IF/THEN return for False NN Excel Discussion (Misc queries) 1 October 6th 06 11:24 AM
if false return a zero outlook help Excel Discussion (Misc queries) 3 February 11th 05 02:23 PM
Differentiate b/w False and 0 with InputBox fn Marcotte A[_2_] Excel Programming 3 June 8th 04 05:10 PM


All times are GMT +1. The time now is 05:09 PM.

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

About Us

"It's about Microsoft Excel"