Solved

A VERY NEWBIW QUESTION ABOUT INPUTBOXES!!

Posted on 1998-11-04
4
190 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 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Title # Comments Views Activity
Saving history changes to sub form 4 52
Using "ScreenUpdating" 6 84
How to set the sa password in a vb6 code for sql connection 9 63
VB6 - Convert HH:MM into Decimal 8 70
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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…

730 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