Solved

programming msgbox.

Posted on 2006-06-14
8
226 Views
Last Modified: 2010-04-07
How can I program YES, NO and CANCEL button on msgbox statement.

I want the msgbox statement to pop up when user presses delete(a button on my form)..the pop up screen should have three buttons, YES, NO and CANCEL..different codes should be executed be each one..

Thank you.
0
Comment
Question by:Aiysha
[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
  • 2
  • 2
8 Comments
 
LVL 8

Accepted Solution

by:
List244 earned 500 total points
ID: 16905452
Dim Result As Integer
Result = MsgBox("MESSAGE", vbYesNoCancel, "TITLE")
If Result = vbYes Then
    MsgBox "Yes"
Else
If Result = vbNo Then
    MsgBox "No"
Else
If Result = vbCancel Then
    MsgBox "Cancel"
End If
End If
End If
0
 
LVL 8

Expert Comment

by:List244
ID: 16905457
Then where I put : MsgBox "Yes" MsgBox "No" and MsgBox "Cancel" you would of course erase that and put the code you want
to take action in those areas.
0
 
LVL 8

Expert Comment

by:List244
ID: 16905471
Another approach would be using a select statement:

Select Case MsgBox("MESSAGE", vbYesNoCancel, "TITLE")
    Case vbYes
        MsgBox "Yes"
    Case vbNo
        MsgBox "No"
    Case vbCancel
        MsgBox "Cancel"
End Select
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 13

Expert Comment

by:Mark_FreeSoftware
ID: 16905488
Dim ret As Long
ret = MsgBox("are you sure you want to delete this file", vbYesNoCancel, "sure?")
If ret = vbYes Then
   'user clicked Yes
ElseIf ret = vbNo Then
   'user clicked no
ElseIf ret = vbCancel Then
   'user clicked cancel
End If

0
 
LVL 13

Expert Comment

by:Mark_FreeSoftware
ID: 16905496

List244 you beat me to it ;)

i had to press f5 before submitting :(
0
 
LVL 10

Expert Comment

by:fostejo
ID: 16906283
Aiysha,

You might also want to have a look at MZ-Tools 3.0 freeware available at http://www.mztools.com/v3/mztools3.htm

This add in to VB6 has a nice 'MsgBox Assistant' which allows you to 'pick and choose' the combination of buttons, icons and other settings you want. You can then preview it to make sure all's ok, prior to generating the required code to support the MsgBox.

(Plus it's got a load of other useful features also, such as Code Review, templates etc.)

cheers,
0
 
LVL 8

Expert Comment

by:List244
ID: 16906324
Aiysha, with all honesty, I do not believe you should go about using that, at least not for message boxes.  Tools that help us
get things done are great.  But message boxes are so simple that you would in my opinion cause yourself nothing but harm
by using such a tool.  It creates a tendency to be lazy much like copy-pasting.  I believe as a beginner to a language you should
practice as much as you can to learn what you can do.  As a beginner taking shortcuts is really not the way to go.  After you
learn and understand concepts, if you are trying to get something done, that is when you should use shortcuts, yet even then
do so carefully.
0
 
LVL 10

Expert Comment

by:fostejo
ID: 16907285
Aiysha,

Although I posted the comment, I do also agree with List244 !!

However, in my defence ;), tools like that 'create' some well structured and working code and allow you to explore the various options available to you that you might have never otherwise considered or 'bumped into' - in this instance, you can 'preview' what's going to the created and then pick apart *how* it does what it does from the code itself.

cheers!
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

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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…

752 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