473,405 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

MessageBox Question

Hey Group,

Sorry to be a pain again but i have the following code:

If MessageBox.Show("Are Your Sure You Want To Send This Email?", "Are Your
Sure You Want To Send This Email?", MessageBoxButtons.OKCancel) Then
Try
SmtpMail.SmtpServer = txtSMTP.Text
Dim Message As MailMessage
Message = New MailMessage()
Message.From = txtFrom.Text
Message.To = txtTo.Text
Message.Subject = "Excellence.Net - Email"
Message.Body = txtMessage.Text
Message.BodyFormat = MailFormat.Text
SmtpMail.Send(Message)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If

All is ok - message pops up and asks yes or cancel, however if i click
Cancel it still send the message? anybody kindly point me in the right
direction?

Ta
MCN
Nov 20 '05 #1
7 1406
"MadCrazyNewbie" <te**@nospam.com> schrieb
If MessageBox.Show("Are Your Sure You Want To Send This Email?", "Are
Your Sure You Want To Send This Email?", MessageBoxButtons.OKCancel)
Then
Try
SmtpMail.SmtpServer = txtSMTP.Text
Dim Message As MailMessage
Message = New MailMessage()
Message.From = txtFrom.Text
Message.To = txtTo.Text
Message.Subject = "Excellence.Net - Email"
Message.Body = txtMessage.Text
Message.BodyFormat = MailFormat.Text
SmtpMail.Send(Message)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If

All is ok - message pops up and asks yes or cancel, however if i
click Cancel it still send the message? anybody kindly point me in
the right direction?


Enable Option Strict.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
Armin,

I`ve enabled Options Strict On but now I get a message saying:

D:\Live Projects\Excellence.Net\EmailForm.vb(240): Option Strict On
disallows implicit conversions from 'System.Windows.Forms.DialogResult' to
'Boolean'.

on
If MessageBox.Show("Are Your Sure You Want To Send This Email?", "Are Your
Sure You Want To Send This Email?", MessageBoxButtons.OKCancel) Then

Any Ideas?

Cheers
MCN

"Armin Zingler" <az*******@freenet.de> wrote in message
news:40*********************@news.freenet.de...
"MadCrazyNewbie" <te**@nospam.com> schrieb
If MessageBox.Show("Are Your Sure You Want To Send This Email?", "Are
Your Sure You Want To Send This Email?", MessageBoxButtons.OKCancel)
Then
Try
SmtpMail.SmtpServer = txtSMTP.Text
Dim Message As MailMessage
Message = New MailMessage()
Message.From = txtFrom.Text
Message.To = txtTo.Text
Message.Subject = "Excellence.Net - Email"
Message.Body = txtMessage.Text
Message.BodyFormat = MailFormat.Text
SmtpMail.Send(Message)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If

All is ok - message pops up and asks yes or cancel, however if i
click Cancel it still send the message? anybody kindly point me in
the right direction?


Enable Option Strict.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
How about testing for the messagebox return being equal to the OK button?

--
Al Reid

"It ain't what you don't know that gets you into trouble. It's what you know
for sure that just ain't so." --- Mark Twain

"MadCrazyNewbie" <te**@nospam.com> wrote in message news:ec********************@karoo.co.uk...
Armin,

I`ve enabled Options Strict On but now I get a message saying:

D:\Live Projects\Excellence.Net\EmailForm.vb(240): Option Strict On
disallows implicit conversions from 'System.Windows.Forms.DialogResult' to
'Boolean'.

on
If MessageBox.Show("Are Your Sure You Want To Send This Email?", "Are Your
Sure You Want To Send This Email?", MessageBoxButtons.OKCancel) Then

Any Ideas?

Cheers
MCN

"Armin Zingler" <az*******@freenet.de> wrote in message
news:40*********************@news.freenet.de...
"MadCrazyNewbie" <te**@nospam.com> schrieb
If MessageBox.Show("Are Your Sure You Want To Send This Email?", "Are
Your Sure You Want To Send This Email?", MessageBoxButtons.OKCancel)
Then
Try
SmtpMail.SmtpServer = txtSMTP.Text
Dim Message As MailMessage
Message = New MailMessage()
Message.From = txtFrom.Text
Message.To = txtTo.Text
Message.Subject = "Excellence.Net - Email"
Message.Body = txtMessage.Text
Message.BodyFormat = MailFormat.Text
SmtpMail.Send(Message)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If

All is ok - message pops up and asks yes or cancel, however if i
click Cancel it still send the message? anybody kindly point me in
the right direction?


Enable Option Strict.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html


Nov 20 '05 #4
"MadCrazyNewbie" <te**@nospam.com> schrieb
If MessageBox.Show("Are Your Sure You Want To Send This Email?",
"Are Your Sure You Want To Send This Email?",
MessageBoxButtons.OKCancel) Then
[...]

All is ok - message pops up and asks yes or cancel, however if
i click Cancel it still send the message? anybody kindly point me
in the right direction?


Enable Option Strict.

I`ve enabled Options Strict On but now I get a message saying:

D:\Live Projects\Excellence.Net\EmailForm.vb(240): Option Strict
On disallows implicit conversions from
'System.Windows.Forms.DialogResult' to 'Boolean'.

on
If MessageBox.Show("Are Your Sure You Want To Send This Email?", "Are
Your Sure You Want To Send This Email?", MessageBoxButtons.OKCancel)
Then

Any Ideas?


The error message says everything you need:
- The return type of the show function is System.Windows.Forms.DialogResult.
- The If statement needs a boolean expression.
=> You have to compare the return value to one of the possible values to get
a boolean expression.
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
Hi Simon,

When you type the = the enum answer comes direct.

If MessageBox.Show("Are Your Sure You Want To Send This Email?", "Are Your
Sure You Want To Send This Email?", MessageBoxButtons.OKCancel) =
DialogResult.OK Then
Cor
Nov 20 '05 #6
You are testing if your messagebox returns True (boolean) while you are
using OK and Cancel buttons, neither of which return true.
"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:R-********************@karoo.co.uk...
Hey Group,

Sorry to be a pain again but i have the following code:

If MessageBox.Show("Are Your Sure You Want To Send This Email?", "Are Your
Sure You Want To Send This Email?", MessageBoxButtons.OKCancel) Then
Try
SmtpMail.SmtpServer = txtSMTP.Text
Dim Message As MailMessage
Message = New MailMessage()
Message.From = txtFrom.Text
Message.To = txtTo.Text
Message.Subject = "Excellence.Net - Email"
Message.Body = txtMessage.Text
Message.BodyFormat = MailFormat.Text
SmtpMail.Send(Message)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If

All is ok - message pops up and asks yes or cancel, however if i click
Cancel it still send the message? anybody kindly point me in the right
direction?

Ta
MCN

Nov 20 '05 #7
MCN,
In addition to the other comments.
If MessageBox.Show("Are Your Sure You Want To Send This Email?", "Are Your
MsgBox(ex.ToString)
I would use one or the other version of MessageBox, not both within a single
program, so as to avoid incompatible parameters...

Of course if you upgraded an existing program and are slowing migrating to
one version than that's understandable... I would consider shadowing the
VB.MsgBox with my own, that has the ObsoleteAttribute on it, so as to
identify all the ones that I need to change... In addition to the
ObsoleteAttribute I would simply call the normal VB.MsgBox...

Hope this helps
Jay

"MadCrazyNewbie" <te**@nospam.com> wrote in message
news:R-********************@karoo.co.uk... Hey Group,

Sorry to be a pain again but i have the following code:

If MessageBox.Show("Are Your Sure You Want To Send This Email?", "Are Your
Sure You Want To Send This Email?", MessageBoxButtons.OKCancel) Then
Try
SmtpMail.SmtpServer = txtSMTP.Text
Dim Message As MailMessage
Message = New MailMessage()
Message.From = txtFrom.Text
Message.To = txtTo.Text
Message.Subject = "Excellence.Net - Email"
Message.Body = txtMessage.Text
Message.BodyFormat = MailFormat.Text
SmtpMail.Send(Message)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End If

All is ok - message pops up and asks yes or cancel, however if i click
Cancel it still send the message? anybody kindly point me in the right
direction?

Ta
MCN

Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Adam | last post by:
I am trying to inherit from MessageBox and i get error in compilation time. The code is: public class MyMessageBox : MessageBox { public static DialogResult Show(int errorCode) { return...
8
by: Dennis C. Drumm | last post by:
I have ordered the book .NET Framework Solutions, In Search of the Lost Win32 API by John Paul Meuller which I think will help answer some of my questions I have regarding making custom...
8
by: Saso Zagoranski | last post by:
Hi! I'm trying to make my own MessageBox... What I would like to know is, how the MessageBox class is implemented? I could have something like: new MyMessageBox().ShowDialog(); but I would...
3
by: Sin | last post by:
I'm currently evaluating VC.NET as the new platform for the company I work for and things are looking grim... We're up against another IDE which took me about 5 minutes to master and I've been...
5
by: Robert Heuvel | last post by:
Hi, this is what I did: public struct SWaitCursor:IDisposable { public SWaitCursor (int i) { Cursor.Current = Cursors.WaitCursor; } void System.IDisposable.Dispose() { Cursor.Current =...
10
by: Andrew | last post by:
Hi, I have a messagebox that pops up due to an event. I did it in javascript. ie. alert("Time's up. Assessment Ended"); I want to capture the OK and Cancel events of this alert messagebox. My...
5
by: roberto | last post by:
Hi at all i have a web application (in vb.net), and i want to use a message box control like System.Windows.Forms.MessageBox control, to show simple messages . I used this but vb.net said me an...
4
by: Larry Woods | last post by:
I have a Messagebox that looks like: MessageBox.Show("There are pending changes for this patient. Do you want to continue to close?", "Pending Changes", MessageBoxButtons.YesNo,...
3
by: VMI | last post by:
I know this isn't the best group to post aspnet question, but the MS asp.net NG hasn't been very helpful lately. I've been trying to add a messagebox following the examples I've seen on the web,...
6
by: Goran Djuranovic | last post by:
Hi all, I have a VB.NET windows application that uses MDI form. When I try to delete a datagrid row from one of the MDI children forms, I use a MessageBox YesNo confirmation, which, after confirmed,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
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...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.