?
Solved

A VERY NEWBIW QUESTION ABOUT INPUTBOXES!!

Posted on 1998-11-04
4
Medium Priority
?
194 Views
Last Modified: 2010-04-30
When I have an Input Box, And press Cancel The Program Crashes, I would like to write an If then Statement to Stop this crashing, So when user clicks on Cancel it doesn't crash but Ends the running program or exits.
0
Comment
Question by:infiniteloop
[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
  • 3
4 Comments
 
LVL 4

Accepted Solution

by:
CraigLazar earned 150 total points
ID: 1443242
Hi infinite loop

HERE is a sample
Put in a command button and see how it works . U will see that if the user presses cancel myvalue is given "" (null) . So then the sample myvalue = "" is then executed . You can also maybe out in there instead of the message box - exit sub - which cancels the subroutine


Private Sub Command1_Click()
Dim Message, Title, Default, MyValue
Message = "Enter a value between 1 and 3"   ' Set prompt.
Title = "InputBox Demo" ' Set title.
Default = "1"   ' Set default.
' Display message, title, and default value.
MyValue = InputBox(Message, Title, Default)

If MyValue = "" Then
    MsgBox "Cancel"
ElseIf MyValue = 1 Then
   MsgBox "1"
Else
MsgBox "Cancel"
End If


This works
adjust it to use it in your app
If you get stuck Mail me the piece of cose at clazar@softnet.co.za and i will look at it quickly

Cheers mate

Craig
 
0
 
LVL 4

Expert Comment

by:CraigLazar
ID: 1443243
Or what you can do is trap the error that vb is sending u .
What is the error vb sends you when you hit the cancel button ?
craig
0
 
LVL 1

Author Comment

by:infiniteloop
ID: 1443244
Thanks,
0
 
LVL 4

Expert Comment

by:CraigLazar
ID: 1443245
No worries mate
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

771 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