-
Feb 26th, 2013, 02:33 PM
#1
Thread Starter
Junior Member
MSGBOX not displaying, OK being automatically selected.
As per the Title, I can only assume I have set some kind of option without realising I have done so, but some MSGBOXes work !!!
This works ...
Code:
If ComboBox1.SelectedItem = Nothing Then myErrorMsg = "No League Selected"
MsgBox(myErrorMsg, MsgBoxStyle.Exclamation)
Exit Sub
End If
This, however, does NOT work & I get a message on the right hand side of the screen that says
User Prompt: Clicked "OK" The user clicked the "OK Button in the MessageBox
Code:
If File.Exists(myRARfile) Then
ZipTest()
Else
myErrorMsg = "ERROR - Aborting ..."
MsgBox(myErrorMsg, vbCritical)
MSWord.Quit()
Exit Sub
End If
This is very frustrating , so if somebody can tell me what on earth is going on here, I'll be eternally grateful !!!
-
Feb 26th, 2013, 02:44 PM
#2
Re: MSGBOX not displaying, OK being automatically selected.
There is no setting that I know of which could cause that behavior automatically. How can you tell this is happening? If you were to put a breakpoint on the MsgBox line, would the breakpoint be hit? What would happen if you stepped forward one line?
The next thing to try would be putting the breakpoint on the MSWord.Quit() line. If the MsgBox is being automatically accepted, the breakpoint should be reached without the MsgBox showing up.
My usual boring signature: Nothing
-
Feb 26th, 2013, 02:47 PM
#3
Re: MSGBOX not displaying, OK being automatically selected.
Well there's nothing in the code that explains it. Do you have any kind of automated keypresses, clicks etc. going on either in this program or another running concurrently with it. I notice that you have a live Word application so is that possibly a source or recipient of such an event?
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Feb 26th, 2013, 05:25 PM
#4
Thread Starter
Junior Member
Re: MSGBOX not displaying, OK being automatically selected.
Originally Posted by Shaggy Hiker
How can you tell this is happening?
I am in Debug mode and I run the program ... that's what it does ... I am baffled (though obviously not an expert ...) !!!
This is the start of the program, it's quite straightforward ...
Code:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
' Ensure that valid data is entered into the DropDown Boxes
If ComboBox1.SelectedItem = Nothing Then
myErrorMsg = "No League Selected"
MsgBox(myErrorMsg, MsgBoxStyle.Exclamation)
Exit Sub
End If
If ComboBox2.SelectedItem = Nothing Then
myErrorMsg = "No Session Selected"
MsgBox(myErrorMsg, MsgBoxStyle.Exclamation)
Exit Sub
End If
'Data has been validated, so Input Form can be closed
Me.Close()
'Set important variables
myLeague = ComboBox1.SelectedItem
mySession = ComboBox2.SelectedItem
myFolder = myNlFolder + ComboBox1.SelectedItem
'Ensure there is a Newsletters Folder for this league & a Current Season Folder inside that Folder ...
'This should never be a problem, as the Outlook Newsletters program writes the Zipped file into this Folder.
If Directory.Exists(myFolder) Then
myFolder = myFolder + "\Current_Season\"
If Directory.Exists(myFolder) Then
'do nothing
Else
Directory.CreateDirectory(myFolder)
End If
Else
Directory.CreateDirectory(myFolder)
myFolder = myFolder + "\Current_Season\"
Directory.CreateDirectory(myFolder)
End If
'The zipped file for this league should already exist
LeftCB = myLeague.ToString
LeftCB = LeftCB.Substring(0, 3)
myRARfile = myFolder + LeftCB + mySession + ".zip"
'Process the Zipped file
If File.Exists(myRARfile) Then
ZipTest()
Else
myErrorMsg = "ERROR - Aborting ..."
MsgBox(myErrorMsg, vbCritical)
MSWord.Quit()
Exit Sub
End If
I would hope that this particular case would never happen, but in my tests it does happen and this weird "OK has been clicked" event is happening !!!
However, there are similar messages later in the program that check for other files and they too are saying I have clicked the OK Button when I clearly haven't !!!
-
Feb 26th, 2013, 05:31 PM
#5
Thread Starter
Junior Member
Re: MSGBOX not displaying, OK being automatically selected.
Originally Posted by dunfiddlin
Well there's nothing in the code that explains it. Do you have any kind of automated keypresses, clicks etc. going on either in this program or another running concurrently with it. I notice that you have a live Word application so is that possibly a source or recipient of such an event?
I don't know ... I don't think so, I did at one point try to use AutoHotKey, but I couldn't get it to work so deleted it, but even so, I don't understand how it would affect some Error Messages and not others !!!
I create the Word document in this program, that is what it's doing, I am not doing anything particularly complicated here, I am creating a Word Document, unzipping a zipped file and opening the files I want in Notepad++ & Excel ... Everything is great apart from these MsgBox problems ... that's why I am so frustrated !!!
-
Feb 26th, 2013, 05:43 PM
#6
Thread Starter
Junior Member
Re: MSGBOX not displaying, OK being automatically selected.
Ok, here is me stepping through the program in Debug mode using F8 ...
No MsgBox opens, it just ends the program !!!
-
Feb 26th, 2013, 05:53 PM
#7
Re: MSGBOX not displaying, OK being automatically selected.
Well there are a few things that I noticed right off the bat, that I personally would change. First, I would use the .net version of MsgBox which is MessageBox. You're also using the "+" sign to concate strings, use the "&" sign instead, + is for adding integers & is for concating strings. But finally I notice that you're closing the form before anything is being done. When you call Me.Close, the rest of your code will not perform. If you don't want the form to be visible when the rest of the code is being performed, call Me.Hide.
-
Feb 26th, 2013, 05:55 PM
#8
Re: MSGBOX not displaying, OK being automatically selected.
Even considering those points, that's some pretty bizarre behavior. MsgBox may be a legacy from VB6, but it still works the same way...I think. I guess that would be my first change. Maybe there IS some difference between the two. Other than that, I'd have to say that I've never seen anything quite like this.
My usual boring signature: Nothing
-
Feb 26th, 2013, 06:01 PM
#9
Re: MSGBOX not displaying, OK being automatically selected.
Is there not a possibility that IntelliTrace is itself the problem? I've never used it but that in itself is significantly the only difference between your debugging and mine (which doesn't do anything like this).
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Feb 26th, 2013, 06:04 PM
#10
Thread Starter
Junior Member
Re: MSGBOX not displaying, OK being automatically selected.
Originally Posted by dday9
Well there are a few things that I noticed right off the bat, that I personally would change. First, I would use the .net version of MsgBox which is MessageBox. You're also using the "+" sign to concate strings, use the "&" sign instead, + is for adding integers & is for concating strings. But finally I notice that you're closing the form before anything is being done. When you call Me.Close, the rest of your code will not perform. If you don't want the form to be visible when the rest of the code is being performed, call Me.Hide.
I will try as you say, I'm no expert, quite the opposite ... I didn't know MsgBox & MessageBox were different, and I use "&" in VBA, I thought "+" was the correct thing to use in VB.net ... different sites, different (not always correct !) help ...
I'm not sure what you mean when you say "When you call Me.Close, the rest of your code will not perform" because it clearly *does" perform, I follow it through, though I can move the Close further down the logical path, but once I have clicked on the Button to take the data from the 2 Dropdown boxes, the data is stored in Variables and the Form is finished with, I don't need to Hide it ...
-
Feb 26th, 2013, 06:10 PM
#11
Thread Starter
Junior Member
Re: MSGBOX not displaying, OK being automatically selected.
Originally Posted by dunfiddlin
Is there not a possibility that IntelliTrace is itself the problem? I've never used it but that in itself is significantly the only difference between your debugging and mine (which doesn't do anything like this).
I don't know, I cannot understand this at all, which is why I am here asking for help !!!
I didn't even know what "IntelliTrace" was until I saw these messages up there ... well, I still don't really, I am a COBOL programmer just trying to learn VB.net & write fairly simple programs yet I keep running into the most absurd problems !!!
-
Feb 26th, 2013, 06:16 PM
#12
Thread Starter
Junior Member
Re: MSGBOX not displaying, OK being automatically selected.
Originally Posted by dday9
First, I would use the .net version of MsgBox which is MessageBox
I just changed all occurrences of MsgBox to MessageBox and have 13 of the longest error messages I have ever seen ... I think I will go and have my dinner, have a decent night's sleep & look again in the morning ... thanks for your hepl so far though, all of you ...
-
Feb 26th, 2013, 06:22 PM
#13
Re: MSGBOX not displaying, OK being automatically selected.
Originally Posted by vodkasoda
I just changed all occurrences of MsgBox to MessageBox and have 13 of the longest error messages I have ever seen ... I think I will go and have my dinner, have a decent night's sleep & look again in the morning ... thanks for your hepl so far though, all of you ...
Yeah, the syntax is a bit more complicated. Slightly disingenuous to say they're equivalent.
MessageBox.Show("Hello", "", MessageBoxButtons.OK, MessageBoxIcon.Warning)
As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"
Reviews: "dunfiddlin likes his DataTables" - jmcilhinney
Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!
-
Feb 26th, 2013, 06:26 PM
#14
Re: MSGBOX not displaying, OK being automatically selected.
Slightly disingenuous to say they're equivalent
Did I say equal? I ment better than :]
-
Feb 27th, 2013, 02:57 AM
#15
Thread Starter
Junior Member
Re: MSGBOX not displaying, OK being automatically selected.
OK, Thank you everybody, dday9 was on the right lines when he said "When you call Me.Close, the rest of your code will not perform". As I said, the code does perform, BUT this is definitely what is affecting the MessageBox display, because if I move the "Me.Close" to after all the validation checks, it works !!!
When the Form is open, the MessageBox commands always display directly on top of it, I can only assume that the Form defines the "Display Window" (for want of a better expression) for the program and if you close the Form, you close the Window and therefore the ability of the MessageBoxes to display properly !!!
If anybody can explain that and/or word it better, please do !!!
Thanks again, though, for all of your help, that has had me baffled for ages !!!
Last edited by vodkasoda; Feb 27th, 2013 at 02:58 AM.
Reason: Spelling
-
Feb 27th, 2013, 07:30 AM
#16
Re: MSGBOX not displaying, OK being automatically selected.
I think you are pretty close with your reasoning for message boxes not showing: closing the window, and subsequently showing a message box would cause the closing of the window operation to 'break'. There is probably a function within the MessageBox call which checks for a parent window to attach to, and if it doesn't exist, simply returns the default option. I haven't investigated this, but it seems reasonable.
MsgBox and MessageBox are identical. MsgBox is a wrapper function around the MessageBox function, while converting the VB6 calling signature to the standard MessageBox signature. Thus, calling the MessageBox function directly short-circuits the unnecessary overhead. Indeed, the MsgBox function exists solely to aid backwards compatibility and conversion from VB6 to .NET.
"Ok, my response to that is pending a Google search" - Bucky Katt.
"There are two types of people in the world: Those who can extrapolate from incomplete data sets." - Unk.
"Before you can 'think outside the box' you need to understand where the box is."
-
Feb 27th, 2013, 09:22 AM
#17
Thread Starter
Junior Member
Re: MSGBOX not displaying, OK being automatically selected.
Thank you for that explanation, it's nice to have something explained in such clear English :-) !!!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|