Solved

VB.net InputBox Cancel/Closed

Posted on 2014-04-08
4
326 Views
Last Modified: 2014-04-11
Hi

I use the following code to ask a user to enter a row number. If the user clicks the Cancel
button or just closes the box, how will I handle this incode

Dim S As string
 S = Globals.ThisAddIn.Application.InputBox(Prompt:="Please enter a row")
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Expert Comment

by:JoseBarroso
ID: 39986077
Dim sText = InputBox(Prompt:="Please enter a row")

        If sText = "" Then
            MsgBox("Cancel or Null")
        Else
            MsgBox(sText)
        End If
0
 
LVL 36

Expert Comment

by:Kimputer
ID: 39986084
Because S is a string,

S = "" when canceled or closed.
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39986281
Checking for a blank string won't tell you if the user clicked Cancel, or actually entered a blank string.

According to the documentation InputBox will return False if Cancel is clicked:
Dim S As Variant
S = Globals.ThisAddIn.Application.InputBox(Prompt:="Please enter a row")

If S = False Then
   '// Use clicked "Cancel" rather than actually entering a blank string
End If

Open in new window

0
 

Author Closing Comment

by:Murray Brown
ID: 39995385
Found that out too. Thanks
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question