473,289 Members | 1,729 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,289 software developers and data experts.

MsgBox won't display

In my code below at the line 'response' a blip sound is heard and the
program exits the sub -- No MsgBox is displayed. What am I doing wrong?

If nonNumberEntered = True Then

msg = "Enter numbers only"

style = MsgBoxStyle.OkOnly

title = "ERROR in cast"

MsgBox(msg, style, title)

response = MsgBox(msg, style, title)

If response = MsgBoxResult.Yes Then

Exit Sub

Else

End If

e.Handled = True

End If
Jan 2 '07 #1
9 3396
Private Sub DisplayMesageBox(ByVal bNumbersEntered As Boolean)
If bNumbersEntered = False Then
MessageBox.Show("Enter numbers only", "ERROR in cast",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub

Call it by:

DisplayMesageBox(False)

I hope this helps,

Newbie Coder
Jan 2 '07 #2
Ivan Jericevich wrote:
In my code below at the line 'response' a blip sound is heard and the
program exits the sub -- No MsgBox is displayed. What am I doing wrong?

If nonNumberEntered = True Then

msg = "Enter numbers only"

style = MsgBoxStyle.OkOnly

title = "ERROR in cast"

MsgBox(msg, style, title)

response = MsgBox(msg, style, title)

If response = MsgBoxResult.Yes Then

Exit Sub

Else

End If

e.Handled = True

End If

There could be a number of problems with the example you've given. In
particular, the "Else" seems to be in the wrong place, so I can only
guess you've incorrectly pasted your example.

To simplify the MsgBox, maybe just use the following (watch for wrapping!) -

If MsgBox("Enter numbers only", MsgBoxStyle.OkOnly, "Error in Cast") =
MsgBoxResult.Yes Then
Exit Sub
End If
Hope this helps!

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Jan 2 '07 #3
Sorry.

Left a little off the last post

Private Sub DisplayMesageBox()
MessageBox.Show("Enter numbers only", "ERROR in cast",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Sub

Simple call:

DisplayMesageBox()

I hope this helps,

Newbie Coder
Jan 2 '07 #4
ShaneO wrote:
Ivan Jericevich wrote:
>In my code below at the line 'response' a blip sound is heard and the
program exits the sub -- No MsgBox is displayed. What am I doing wrong?
Sorry, after re-reading your OP, I should have suggested the following -

If nonNumberEntered = True Then
MsgBox("Enter numbers only", MsgBoxStyle.OkOnly, "Error in Cast")
Exit Sub
Else
e.Handled = True
End If
ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Jan 2 '07 #5
Why do you need a MessageBoxResult of YES in an OK only MessageBox?

How will that ever be called because there is no YES button?

I hope this helps,

Newbie Coder.
Jan 2 '07 #6
Newbie Coder wrote:
Why do you need a MessageBoxResult of YES in an OK only MessageBox?

How will that ever be called because there is no YES button?

I hope this helps,

Newbie Coder.

I corrected that. :-)

ShaneO

There are 10 kinds of people - Those who understand Binary and those who
don't.
Jan 2 '07 #7
Ivan,
As the others suggest I normally use MessageBox.Show instead of MsgBox,
however I don't see that is a problem here!

The first problem I see is you are call MsgBox twice, which is annoying at
best.
MsgBox(msg, style, title)
response = MsgBox(msg, style, title)
Another problem that I noticed is the Message Box is not visible if I
attempt to single step the code under Vista x64. I needed to use Alt+Tab (or
use Flip 3D) to find the Message Box & show it. However I suspect this is
more an artifact of not having a window shown when I tested the code rather
then a Vista specific problem.

One of the reasons I prefer MessageBox.Show over MsgBox is that I have
control over which window "owns" the message box.

MessageBox.Show(Me, msg, title, MessageBoxButtons.OK)

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Ivan Jericevich" <iv**@oberon.co.zawrote in message
news:%2*****************@TK2MSFTNGP03.phx.gbl...
In my code below at the line 'response' a blip sound is heard and the
program exits the sub -- No MsgBox is displayed. What am I doing wrong?

If nonNumberEntered = True Then

msg = "Enter numbers only"

style = MsgBoxStyle.OkOnly

title = "ERROR in cast"

MsgBox(msg, style, title)

response = MsgBox(msg, style, title)

If response = MsgBoxResult.Yes Then

Exit Sub

Else

End If

e.Handled = True

End If

Jan 2 '07 #8
Doh! (clicked send too soon).

Can you give more details on the type of application that the code appears
in: (Windows Forms, Windows Service, Web Form, Web Service) Plus details of
where the code is being called, such as what event is being handled when you
call your routine...

--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Ivan Jericevich" <iv**@oberon.co.zawrote in message
news:%2*****************@TK2MSFTNGP03.phx.gbl...
In my code below at the line 'response' a blip sound is heard and the
program exits the sub -- No MsgBox is displayed. What am I doing wrong?

If nonNumberEntered = True Then

msg = "Enter numbers only"

style = MsgBoxStyle.OkOnly

title = "ERROR in cast"

MsgBox(msg, style, title)

response = MsgBox(msg, style, title)

If response = MsgBoxResult.Yes Then

Exit Sub

Else

End If

e.Handled = True

End If

Jan 2 '07 #9
Ivan,

I would at least remove one of those showings of the messagebox.

MsgBox(msg, style, title)

I never use this one, however when I tested it, it gave strange behaviour.
Different in step by step (twice displayed) than while running (once
displayed).

Cor
"Ivan Jericevich" <iv**@oberon.co.zaschreef in bericht
news:%2*****************@TK2MSFTNGP03.phx.gbl...
In my code below at the line 'response' a blip sound is heard and the
program exits the sub -- No MsgBox is displayed. What am I doing wrong?

If nonNumberEntered = True Then

msg = "Enter numbers only"

style = MsgBoxStyle.OkOnly

title = "ERROR in cast"

MsgBox(msg, style, title)

response = MsgBox(msg, style, title)

If response = MsgBoxResult.Yes Then

Exit Sub

Else

End If

e.Handled = True

End If


Jan 2 '07 #10

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

Similar topics

0
by: Constantine Kakoushis | last post by:
Hi, I was previously running from my home test server (Suse 9.0) but have recently uploaded to my ISP. Since then (I think) images that have been resized on the server (resulting in .pjpeg...
4
by: seamus | last post by:
I transferred a new web that worked last week to my production server. Now none of my asp pages will display. Any suggestions?
6
by: Kenny G | last post by:
Reference the below sub: I can't get the message box to close and therefore the user can't enter anything - Y or N in the OralAntibiotics box. Your help is appreciated. Private Sub...
4
by: dp | last post by:
After looking and looking, it appears that Access ADPs graphic query designer won't display: update customer set = . from customer, where customer. = .; It comes up with the "Query...
1
by: Beowulf | last post by:
I'm having some difficulty and I can't for the life of me figure out why. I have a main report, rptMain, that contains a report header (displays the AppTitle), 3 group headers (one is a header...
10
by: z | last post by:
I just installed Visual Studio .Net with Framework 1.1. I already had VB6 SP6 installed. I wanted to do a quick "hello world" example in VB.Net. The code is here: Private Sub...
4
by: Ryan Knopp | last post by:
So if I create a gif image using the source below the image won't display at all in IE. I just get a red X. It displays right with Firefox and it also displays okay if i open it up in Paint or...
1
by: calfstad | last post by:
Title says it all. I am using dreamweaver to create a very simple page and have linked an external style sheet. I have created a tag for all images (not link images) to have a 1px white border. The...
3
by: JCCDEVEL | last post by:
Hello, I'm writing a basic query in Sql Server Mgmt Studio 2005. Basically, I'm trying to query a table to get all "issues" reported in a month by "Project Category". The query is working fine...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.