MessageBox.Show() Not showing text in popup box nor in button

ZorroRojo

Member
Joined
Oct 9, 2006
Messages
15
Location
Virginia, US
Programming Experience
Beginner
This is my first post here and I am hoping I have posted in the right place.

I know almost nothing about VB.NET but am trying to test some code I developed based off of examples I found. The code is supposed to give me all the file names and create dates for the files in a specific directory. I know the code works for giving me the correct file names (because I have tested it in a Sripting Task in an SSIS package for SQL Server 2005) but when I put it in VB.NET (with a few minor adjustments) I can't see any of the file names nor create dates because the pop up box is blank. I can't even see the words OK on the button.

All I did was create a new project in Visual Studio .NET 2003 and pasted the code into the form that was there. Here is the code I am using:

VB.NET:
Imports System
Imports System.Data
Imports System.Math
Imports System.IO
 
Public Class Form1
Inherits System.Windows.Forms.Form
 
#Region " Windows Form Designer generated code "
 
Public Sub New()
MyBase.New()
 
'This call is required by the Windows Form Designer.
InitializeComponent()
 
'Add any initialization after the InitializeComponent() call
 
End Sub
 
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
 
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
 
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer. 
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(512, 190)
Me.Name = "Form1"
Me.Text = "Why"
 
End Sub
 
#End Region
 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 
FileNames(New DirectoryInfo("c:\Imports\LionShares"))
 
End Sub
 
Sub FileNames(ByVal dir As DirectoryInfo)
 
MessageBox.Show("Hello", "test", MessageBoxButtons.YesNo)
 
Dim objFile As FileInfo
 
For Each objFile In dir.GetFiles("*.txt")
MessageBox.Show(objFile.FullName & " " & objFile.CreationTime)
Next
 
objFile = Nothing
End Sub
End Class
After putting the code in I selected Build and then selected the form name. After that I went to Debug and selected Start. A blank pop up comes up for each file that is there. How do I get the file name to appear in the pop up and the OK or Yes/No to show up in the buttons?
 
Last edited by a moderator:

Raven65

Well-known member
Joined
Oct 4, 2006
Messages
305
Programming Experience
3-5
Your form code looks like...I even tested it just fine on my box.

What OS are you trying this on? DirectoryInfo should be fine on anything 98+...

Have you tried changing just the path to ensure there are no access violations?
 

Raven65

Well-known member
Joined
Oct 4, 2006
Messages
305
Programming Experience
3-5
Well, originally I had built it in VS05/XPSP2, but I tested it again just now in your exact environment and it worked just fine. =\ Like I said the code looks good I see no problem, thats why I was curious about your environment...

Got a weird one here it seems..I'll keep looking just wanted to get an answer back out.

Edit:

Oh, one note..I see your profile lists .NET 1.1, is that accurate? That would be a difference in the two testing environments if so...
 
Last edited:

ZorroRojo

Member
Joined
Oct 9, 2006
Messages
15
Location
Virginia, US
Programming Experience
Beginner
Thanks for your help.

My guess would be I am compiling it or doing something else wrong because I really don't know much about the development environment for VB.NET. At first I couldn't even get anything to run when I hit start it just complained that there was no file or something. I finally stumbled around and found how to get it to run.

Yes, when I checked the studio program it said I was using 1.1 2003.
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,553
Location
Norway
Programming Experience
10+
There is a known issue with some version of Mcafffe antivirus where the messagebox turn all blank.
 

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,524
Location
Lansing, MI; USA
Programming Experience
10+
if you're using mcafee virus scan 8.0 and older there are conflicts with the .net framework (at least the 1.1 framework)
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,553
Location
Sydney, Australia
Programming Experience
10+
If you're using McAfee you need to fix the issue because it is not limited to MessageBoxes. McAfee have provided a patch that's available to all licensed users. Alternatively you can disable buffer overflow (I think that's it, or something similar) protection in McAfee. That makes it less secure of course.
 

ZorroRojo

Member
Joined
Oct 9, 2006
Messages
15
Location
Virginia, US
Programming Experience
Beginner
Or would the problem also go away if we upgrade to .NET 2.0?

I don't know if my work will let me learn a lot of VB.NET and so that is the reason my priority is not to get the problem fixed but to work around it.

Thanks again everyone. I like this forum but am having troubles staying logged in and so I don't know if I will keep coming back here unless I can figure out how to stay logged in. I tried to post something in the forum bug area but so far have not been able to.
 

ZorroRojo

Member
Joined
Oct 9, 2006
Messages
15
Location
Virginia, US
Programming Experience
Beginner
How can I modify the code I originally posted to display the results in the form?

I have tried adding code such as Console.WriteLine("Hello") but never see it on the form or where ever it is supposed to show up. Or is it also not showing up due to the same problem I have with the pop up's showing nothing?
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,553
Location
Sydney, Australia
Programming Experience
10+
You may also like to use Debug.WriteLine. All the methods of the Debug class are only executed while you're debugging, so it's completely safe to leave them in your release code. That means that you don't have to keep adding and removing lines of code that may be useful again while debugging in the future.
 

cjard

Well-known member
Joined
Apr 25, 2006
Messages
7,052
Programming Experience
10+
You can also put a breakpoint at any suitable section you wish to test and write into the Immediate Window:

?<line of code>



For example if you line of code is:

Dim s as String = "The collection contains " & myColl.Count & "items"


you can break on this line, and write this into the immediate window:

?"The collection contains " & myColl.Count & "items"

The string that would be formed by this line of code, is printed to the immediate window. THis method uses the same libraries as JMcIlhinney's method of Debug.Write but does not require editing your source code.


Additionally, rather than printing things out all the time, you should get used to the locals window or select-evaluation.
When the program execution is halted on a breakpoint, point the mouse cursor to an object on a line in scope and already executed. The object should turn into a drop down alowing you to interrogate the properties. Additionally, in my example above, you could have highlighted the entire section "The collection contains " & myColl.Count & "items" and pointed to it. A tooltip would appear with the result of the string evaluation.
On the Debug menu, pick Other Windows>> Locals
Locals is a listing of all locally accessible variables. If you ahve objects that are properties/attributes of the form class, then expand the ME node, and look for them. Other items in the locals window are ones immediately available in scope. If you had just stepped over a line of code saying "Dim s as New String" then an entry for S would appear in your Locals window.

There are many more options than the primitive MessageBox.Show method of debugging. I encourage you to explore them.

If any of this fails to make sense, I may prepare a movie for you highlighting the features
 

ZorroRojo

Member
Joined
Oct 9, 2006
Messages
15
Location
Virginia, US
Programming Experience
Beginner
Thank you both. I like the Debug method as it is similar to something I do when writing stored procedures. The part about highlighting and pointing sounds good too then I wouldn't even need extra lines of code. My best guess as to where the locals window is, is that would be where I see all the VB code. Or is it somewhere else?
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,553
Location
Norway
Programming Experience
10+
When you start app for debugging and go back to Visual Studio to look there are windows below the code, the tabs are named 'Locals' 'Immediate' and 'Output' etc. If they are not there you can activate them from main menu 'Debug' > 'Windows' >
 

ZorroRojo

Member
Joined
Oct 9, 2006
Messages
15
Location
Virginia, US
Programming Experience
Beginner
I see Output which is where I have been seeing the output from the Console.WriteLine command. I also see tabs labeled Task List, Index Result, and Command Window (which I activated the way you said) when I click on that tab then I see Command Window - Immediate. The only other one for me to activate which I just did was Breakpoints. Is one of these what is referred to as locals?
 
Top Bottom