?
Solved

A VERY NEWBIW QUESTION ABOUT INPUTBOXES!!

Posted on 1998-11-04
4
Medium Priority
?
197 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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

839 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