473,594 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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?", MessageBoxButto ns.OKCancel) Then
Try
SmtpMail.SmtpSe rver = 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.BodyFor mat = MailFormat.Text
SmtpMail.Send(M essage)
Catch ex As Exception
MsgBox(ex.ToStr ing)
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 1416
"MadCrazyNewbie " <te**@nospam.co m> schrieb
If MessageBox.Show ("Are Your Sure You Want To Send This Email?", "Are
Your Sure You Want To Send This Email?", MessageBoxButto ns.OKCancel)
Then
Try
SmtpMail.SmtpSe rver = 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.BodyFor mat = MailFormat.Text
SmtpMail.Send(M essage)
Catch ex As Exception
MsgBox(ex.ToStr ing)
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\Excell ence.Net\EmailF orm.vb(240): Option Strict On
disallows implicit conversions from 'System.Windows .Forms.DialogRe sult' to
'Boolean'.

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

Any Ideas?

Cheers
MCN

"Armin Zingler" <az*******@free net.de> wrote in message
news:40******** *************@n ews.freenet.de. ..
"MadCrazyNewbie " <te**@nospam.co m> schrieb
If MessageBox.Show ("Are Your Sure You Want To Send This Email?", "Are
Your Sure You Want To Send This Email?", MessageBoxButto ns.OKCancel)
Then
Try
SmtpMail.SmtpSe rver = 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.BodyFor mat = MailFormat.Text
SmtpMail.Send(M essage)
Catch ex As Exception
MsgBox(ex.ToStr ing)
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.co m> wrote in message news:ec******** ************@ka roo.co.uk...
Armin,

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

D:\Live Projects\Excell ence.Net\EmailF orm.vb(240): Option Strict On
disallows implicit conversions from 'System.Windows .Forms.DialogRe sult' to
'Boolean'.

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

Any Ideas?

Cheers
MCN

"Armin Zingler" <az*******@free net.de> wrote in message
news:40******** *************@n ews.freenet.de. ..
"MadCrazyNewbie " <te**@nospam.co m> schrieb
If MessageBox.Show ("Are Your Sure You Want To Send This Email?", "Are
Your Sure You Want To Send This Email?", MessageBoxButto ns.OKCancel)
Then
Try
SmtpMail.SmtpSe rver = 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.BodyFor mat = MailFormat.Text
SmtpMail.Send(M essage)
Catch ex As Exception
MsgBox(ex.ToStr ing)
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.co m> schrieb
If MessageBox.Show ("Are Your Sure You Want To Send This Email?",
"Are Your Sure You Want To Send This Email?",
MessageBoxButto ns.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\Excell ence.Net\EmailF orm.vb(240): Option Strict
On disallows implicit conversions from
'System.Windows .Forms.DialogRe sult' to 'Boolean'.

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

Any Ideas?


The error message says everything you need:
- The return type of the show function is System.Windows. Forms.DialogRes ult.
- 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?", MessageBoxButto ns.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.co m> 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?", MessageBoxButto ns.OKCancel) Then
Try
SmtpMail.SmtpSe rver = 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.BodyFor mat = MailFormat.Text
SmtpMail.Send(M essage)
Catch ex As Exception
MsgBox(ex.ToStr ing)
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.ToStr ing)
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 ObsoleteAttribu te on it, so as to
identify all the ones that I need to change... In addition to the
ObsoleteAttribu te I would simply call the normal VB.MsgBox...

Hope this helps
Jay

"MadCrazyNewbie " <te**@nospam.co m> 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?", MessageBoxButto ns.OKCancel) Then
Try
SmtpMail.SmtpSe rver = 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.BodyFor mat = MailFormat.Text
SmtpMail.Send(M essage)
Catch ex As Exception
MsgBox(ex.ToStr ing)
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
9600
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 DialogResult.OK; }
8
13099
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 MessageBoxes, but that isn't going to be here for a few days. So, I thought I would ask you guys how to put one of hte standard MessageBox icons, such as MessageBoxIcon.Exclamation, into my custom MessageBox. Thanks,
8
2443
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 like the solution used by MessageBox, where you call the static Show() method, which returns a DialogResult value...
3
7420
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 bitching at .NET for the whole day now not being able to do something as simple as showing a textbox's content in a damn MessageBox... The TextBox.Text is a String... MessageBox takes a LPCSTR (plain single byte char*)... All our current code base...
5
3179
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 = Cursors.Default;
10
6001
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 code is in C#/ASP.NET. TIA. Andrew.
5
9165
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 exception: Imports System.Windows.Forms 'Dim msgBox As MessageBox 'msgBox.Show("User updating successful.", MessageBoxButtons.OK, MessageBoxIcon.Information)
4
1998
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, MessageBoxIcon.Question) When I execute the Messagebox.Show, then press either 'Yes' or 'No' I get 25 of the following Messageboxes: "incorrect syntax near the keyword WHERE"
3
6491
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, but with no luck. I have an aspx page where the user enters a bunch of data and clicks 'Submit'. When the user clicks on the 'Submit', I want to run an SP that returns true/false depending on the data. If false, then my MessageBox will pop up...
6
3484
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, minimizes the MDI form. Why is this happening and how can I prevent it? Important thing to say is, if I use just "OK" MessageBox, it DOES NOT minimize the MDI parent. TIA Goran
0
7876
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8251
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8372
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8234
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5739
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5408
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3897
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1478
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1210
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.