View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Inputbox question

Hi Wilro85,

Try something like:

'=====================
Public Sub TesterX()
Dim sStr As String

sStr = InputBox(Prompt:="Please type your name", _
Title:="InputBox Demo")
If StrPtr(sStr) = 0 Then
MsgBox "You pressed Cancel"
Else
If Len(sStr) = 0 Then
MsgBox "OK was pressed but no entry was made."
Else
MsgBox "Your entry was: " & sStr
End If
End If
End Sub
'<<=====================


---
Regards,
Norman



"wilro85" wrote in
message ...

When using an inputbox, how do you keep it from generating an error if
the user clicks cancel? I want them to be able to cancel it, just not
have to think about whether they should end or debug.

So far I've had no luck with things such as

....
if VBcancel then end
elseif
....

because that cuts my program short. What is the trick?


--
wilro85
------------------------------------------------------------------------
wilro85's Profile:
http://www.excelforum.com/member.php...o&userid=26935
View this thread: http://www.excelforum.com/showthread...hreadid=466059