Hey guys any one know how to make a msg that is vbyesnocancel And do a different command depending on which the user pressed
For example when closing the window ..... have the option of sve and close,close or cancel.
You don't use an if statement do you?
Daniel(~_~)
9 2138
Yes you use if for this
try like this -
rep=msgbox("Do you want to save",vbyesnocancel + vbquestion,"Save Data...!")
-
if rep=vbyes then
-
'save the data
-
elseif rep=vbno then
-
'don't save the data
-
else
-
'do nothing
-
end if
-
Yes you use if for this
try like this -
rep=msgbox("Do you want to save",vbyesnocancel + vbquestion,"Save Data...!")
-
if rep=vbyes then
-
'save the data
-
elseif rep=vbno then
-
'don't save the data
-
else
-
'do nothing
-
end if
-
Does this vbYesNoCancel a constant value of message box property? Or am I wrong? All I know is vbRetryCancel . For vbYesNoCancel, we can combine vbYesNo + vbCancel. : )
Does this vbYesNoCancel a constant value of message box property? Or am I wrong? All I know is vbRetryCancel . For vbYesNoCancel, we can combine vbYesNo + vbCancel. : )
i don't remember exactly . I don't have vb 6.0 in my office.
try to use vbYesNo instead.
i don't remember exactly . I don't have vb 6.0 in my office.
try to use vbYesNo instead.
Guys i using vb08 inwhich vbyesnocancel does exist.
your solution worked.
Thanks
Daniel(~_~)
Guys i using vb08 inwhich vbyesnocancel does exist.
your solution worked.
Thanks
Daniel(~_~)
ok, you are most welcome .
Just one thing. For multiple choices based on a single value like this, I'd recommend using Select Case rather than If.
The YesNoCancelMsgBox function shows how to handle vbYes, vbNo, vbCancel and clicking the top right close button. The YesNoCancelMsgBox function below it shows how to call it and use the result as the message string in another message box. The result can also be applied to a string variable in the same way with one line of code instead of having paste all of the code repeatedly. (Integers are better to return but I instead used strings to simplify.) - Public Function YesNoCancelMsgBox(Message As String, Title As String) As String
-
Dim Result As Integer
-
Result = MsgBox(Message, vbQuestion + vbYesNoCancel, Title)
-
-
Select Case Result
-
Case 7
-
YesNoCancelMsgBox = "No"
-
Case 6
-
YesNoCancelMsgBox = "Yes"
-
Case 2
-
YesNoCancelMsgBox = "Cancel"
-
Case Else
-
YesNoCancelMsgBox = "Close Button"
-
End Select
-
End Function
-
Private Sub CallYesNoCancelMsgBox()
-
MsgBox YesNoCancelMsgBox("Choose Yes, No, Cancel or the top right Close button.", "Message Box Test..."), vbExclamation + vbOKOnly, "Message Box Test Results"
-
End Sub
Thanks for that, seal6039. Handy stuff.
I would make a couple of minor suggestions, though. - In VB6, it's generally better to use Long rather than Integer, for performance reasons. (Of course performance is unlikely to be an issue in this case, since you are waiting on the user anyway.)
- I believe it makes for more easily readable code if you use the built-in constants rather than literal values. For example, vbYes rather than 6, and so on.
thanks seal6039 for the nicely crafted code.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Andras Gilicz |
last post by:
Hi VB fans
I'm working on a relatively large project in VB6 with about a dozen
forms, including graphs, labels, text boxes, etc. The software itself
is actually a flow simulator with more or...
|
by: Mark |
last post by:
Hi,
I'm running visual studio 2003, and am now receiving the error "The
Operation Could Not Be Completed" when attempting to add a form / control or
component class to a project. I can add any...
|
by: Alex Wisnoski |
last post by:
I have an A97 application that I am modifying. I have created an
unbound form, "zfrmTestEnterPlacements", with a subform,
"zsfrmSelectPlacement". The intent is to use a combo box on the
primary...
|
by: martin |
last post by:
Hi,
I am copying an xml file like so.
Dim xmlDoc As New XmlDocument
xmlDoc.Load("C:\Program Files\Templates\message.msg")
Console.WriteLine("Tmaplate loaded")
xmlDoc.Save("C:\Program...
|
by: Joel |
last post by:
Creating an Outlook Add-in with VB.NET to automatically save messages
for users. The problem occurs if I create a reference (withevents) to
the MailItem Object when a new Inspector object is...
|
by: Jim in Arizona |
last post by:
I've been using an example out of a book to be able to edit the rows in a
database. I am getting the following error:
========================================================...
|
by: Svein Terje Gaup |
last post by:
Hi, I have some code on .NET 2.0 that creates a TransactionScope and
then tries to open a SQL Connection.
When I try to open the connection, I get this error:
Test method...
|
by: thesinnerishere |
last post by:
hello!
how can the save task be completed when the popup is closed in javascript.
for eg i have this save function. so when i click on the OK of confirmation dialog box , the popup should also...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| | |