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
Solved

A VERY NEWBIW QUESTION ABOUT INPUTBOXES!!

Posted on 1998-11-04
4
189 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
  • 3
4 Comments
 
LVL 4

Accepted Solution

by:
CraigLazar earned 50 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

840 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