main form gone AWOL

Main form executes, but I can't see it...

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 2502 Views - Last Post: 03 October 2008 - 02:35 PM Rate Topic: -----

#1 dirigible  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-October 08

main form gone AWOL

Post icon  Posted 02 October 2008 - 11:58 AM

I can't find my main form. (Go ahead and laugh.)

I had this application working correctly. I am just tweaking it. But now, when I enter debug mode, or if I publish and run the application, I can't see the main form.
I know that the code in the Load_form1 sub executes, because the message boxes I put in for testing display correctly. But they're just floating against my desktop!

Any thought on what may be causing this and how to correct it?

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: main form gone AWOL

#2 William_Wilson  Icon User is offline

  • lost in compilation
  • member icon

Reputation: 205
  • View blog
  • Posts: 4,807
  • Joined: 23-December 05

Re: main form gone AWOL

Posted 02 October 2008 - 12:29 PM

if you share the code it will probably go a lot faster.
Was This Post Helpful? 0
  • +
  • -

#3 dirigible  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-October 08

Re: main form gone AWOL

Posted 02 October 2008 - 12:34 PM

I didn't post the code because I didn't know what section would cause this... here's all my Form_Load code (I apologize for the mess... I'm learning on the fly):

Public Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

		'sets up doc buttons on load
		Dim xCount As Integer

		Dim endCheck As Integer
		Dim buttonSetupFileReader As System.IO.StreamReader
		Dim buttonName As String
		Dim line As String
		buttonSetupFileReader = _
		My.Computer.FileSystem.OpenTextFileReader("C:\ionic\buttonSetup.txt")
		xCount = 0
		docButtons(xCount) = buttonSetupFileReader.ReadLine()
		If docButtons(xCount) = "end" Then
			endCheck = 0
		Else
			endCheck = 1
		End If

		While endCheck = 1 And xCount < 10
			buttonName = "docButton" & (xCount)
			Me.Controls(buttonName).Text = docButtons(xCount)
			Me.Controls(buttonName).Visible = True
			docLaunch(xCount) = buttonSetupFileReader.ReadLine()
			xCount = xCount + 1
			docButtons(xCount) = buttonSetupFileReader.ReadLine()
			If docButtons(xCount) = "end" Then endCheck = 0
		End While

		'sets up listBox1 on load and populates array containing listBox2 data
		Dim listSetupFileReader As System.IO.StreamReader
		listSetupFileReader = _
		My.Computer.FileSystem.OpenTextFileReader("C:\ionic\listSetup.txt")
		Dim x As Integer = 0
		Dim lb1Count As Integer
		Dim lb2Count As Integer
		Dim lb2Index(100, 100) As String
		Dim lb1PdfIndex(100) As String

		For x = 0 To 99
			lb1Items(x) = New lb1Entry

			'Dim myLb1Item As lb1Entry = New lb1Entry
			' myLb1Item.buttonName = "empty"
			'  myLb1Item.pdfName = 0
			' lb1Items(x) = myLb1Item
		Next

		For x = 0 To 99
			lb2Items(x) = New lb2Entry

			'Dim myLb1Item As lb1Entry = New lb1Entry
			' myLb1Item.buttonName = "empty"
			'  myLb1Item.pdfName = 0
			' lb1Items(x) = myLb1Item
		Next

		lb1Count = 0
		lb2Count = 0

		While listSetupFileReader IsNot "end"
			line = listSetupFileReader.ReadLine()
			If line = "b1Btn" Then
				lb1Items(lb1Count).buttonName = listSetupFileReader.ReadLine()  'fills class(lb1Count) with name of lb1 button
				MsgBox("b1Btn: " & lb1Items(lb1Count).buttonName)
				If lb1Items(lb1Count).buttonName IsNot "end" Then
					ListBox1.Items.Add(lb1Items(lb1Count).buttonName) 'adds class(lb1Count) entry to lb1
				End If
			ElseIf line = "b1Lch" Then
				lb1Items(lb1Count).pdfName = listSetupFileReader.ReadLine() 'fill class(lb1Count) with name of corresponding pdf filename
				MsgBox("b1Lch: " & lb1Items(lb1Count).pdfName)
				lb1Count = lb1Count + 1 ' after lb1 entry is complete w/pdf name, advances lb1 index
			ElseIf line = "b2Btn" Then
				lb1Items(lb1Count).spawnLb2 = True
				lb2Items(lb2Count).lb1Link = lb1Count
				lb2Items(lb2Count).buttonName = listSetupFileReader.ReadLine() 'fills class(lb2Count) with name of lb2 button
				MsgBox("b2Btn: " & lb2Items(lb2Count).buttonName)
				ListBox2.Items.Add(lb2Items(lb2Count).buttonName) 'adds class(lb2Count) entry to lb2

			ElseIf line = "b2Lch" Then
				lb2Items(lb2Count).pdfName = listSetupFileReader.ReadLine() 'fill class(lb2Count) with name of corresponding pdf filename
				MsgBox("b2Lch: " & lb2Items(lb2Count).pdfName)
				lb2Count = lb2Count + 1 ' after lb2 entry is complete w/pdf name, advances lb2 index
			End If

		End While

	End Sub


If anything else would be helpful in addressing this, let me know!

Thanks!
Was This Post Helpful? 0
  • +
  • -

#4 Reverand Dave  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 375
  • Joined: 27-July 08

Re: main form gone AWOL

Posted 02 October 2008 - 12:44 PM

I think this is .NET.
Was This Post Helpful? 0
  • +
  • -

#5 dirigible  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-October 08

Re: main form gone AWOL

Posted 02 October 2008 - 12:46 PM

VB in Visual Studio 2008
Was This Post Helpful? 0
  • +
  • -

#6 Reverand Dave  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 3
  • View blog
  • Posts: 375
  • Joined: 27-July 08

Re: main form gone AWOL

Posted 02 October 2008 - 01:08 PM

VB in VS 2008 is .net
Was This Post Helpful? 0
  • +
  • -

#7 dirigible  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-October 08

Re: main form gone AWOL

Posted 02 October 2008 - 01:16 PM

I stand corrected :D
In any event, until this gets moved to the .NET forum, any thoughts?
Was This Post Helpful? 0
  • +
  • -

#8 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2271
  • View blog
  • Posts: 9,500
  • Joined: 29-May 08

Re: main form gone AWOL

Posted 02 October 2008 - 01:43 PM

The Form Load events happens before the form is displayed.
Was This Post Helpful? 0
  • +
  • -

#9 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: main form gone AWOL

Posted 02 October 2008 - 01:44 PM

Moved to VB.NET :)
Was This Post Helpful? 0
  • +
  • -

#10 jacobjordan  Icon User is offline

  • class Me : Perfection
  • member icon

Reputation: 113
  • View blog
  • Posts: 1,499
  • Joined: 11-June 08

Re: main form gone AWOL

Posted 02 October 2008 - 04:14 PM

Adam is correct. The Load event runs through prior to your form being shown. If your intention is to have that code run through right after your form shows, you must create a Shown (not Load) event for your form. Then, put your code in that. This should make your form visible once the message boxes show.

This post has been edited by jacobjordan: 02 October 2008 - 04:14 PM

Was This Post Helpful? 0
  • +
  • -

#11 dirigible  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-October 08

Re: main form gone AWOL

Posted 03 October 2008 - 06:20 AM

View Postjacobjordan, on 2 Oct, 2008 - 04:14 PM, said:

Adam is correct. The Load event runs through prior to your form being shown. If your intention is to have that code run through right after your form shows, you must create a Shown (not Load) event for your form. Then, put your code in that. This should make your form visible once the message boxes show.

But I haven't had to use a form1_Shown event in any program I've written previously... the main form (Form1) is shown automatically on launch.
In any event, using the code
 Private Sub form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Dim form1 As New Form
		form1.Show()

Results in a new, empty form being displayed--not the one that contains my buttons, etc.

Changing the Form1_Load event (code posted earlier) to a Form1_Shown event just doesn't seem to make a difference. My msg boxes still display, but Form1 doesn't.

Here's the thing:
When I create a new app with a single form (Form1 by default) and then debug, that form displays automatically. I don't have create a Shown event. Why is that my current app (which used to work fine, I might add) doesn't do this anymore? It must be a simple change I made somewhere that's goofing this up.

Thanks for your help!

This post has been edited by dirigible: 03 October 2008 - 06:40 AM

Was This Post Helpful? 0
  • +
  • -

#12 magicmonkey  Icon User is offline

  • D.I.C Regular

Reputation: 106
  • View blog
  • Posts: 484
  • Joined: 12-September 08

Re: main form gone AWOL

Posted 03 October 2008 - 07:27 AM

What happens after you close all the Message Boxes that pop up? Does the form then show? You have to remember that msgbox shows a modal form, in other words the code after the msgbox will not get executed until the message box is closed.

So by placing msgbox in your load event you will not see the form until the message box is closed.

Now if after you clear all these message boxes you are poping up if the form still doesn't show then I will dig deeper into your code and see if something else sticks out.

Oh and one more thing, if you are using these message boxes for debuging purposes DONT. Instead use Debug.WriteLine("hello there") to send the data to your debug output window within visual studio. This way you do not get annoyed with pop ups and you can look at the history of information sent to the output window while the application is running.

This post has been edited by magicmonkey: 03 October 2008 - 07:28 AM

Was This Post Helpful? 0
  • +
  • -

#13 dirigible  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-October 08

Re: main form gone AWOL

Posted 03 October 2008 - 07:38 AM

View Postmagicmonkey, on 3 Oct, 2008 - 07:27 AM, said:

What happens after you close all the Message Boxes that pop up? Does the form then show? You have to remember that msgbox shows a modal form, in other words the code after the msgbox will not get executed until the message box is closed.

So by placing msgbox in your load event you will not see the form until the message box is closed.

Now if after you clear all these message boxes you are poping up if the form still doesn't show then I will dig deeper into your code and see if something else sticks out.

Oh and one more thing, if you are using these message boxes for debuging purposes DONT. Instead use Debug.WriteLine("hello there") to send the data to your debug output window within visual studio. This way you do not get annoyed with pop ups and you can look at the history of information sent to the output window while the application is running.



When I close the message boxes, I just end up looking at the empty desktop. The form doesn't display.

I didn't know about the debug.writeline function... thanks for the tip!
Was This Post Helpful? 0
  • +
  • -

#14 magicmonkey  Icon User is offline

  • D.I.C Regular

Reputation: 106
  • View blog
  • Posts: 484
  • Joined: 12-September 08

Re: main form gone AWOL

Posted 03 October 2008 - 09:14 AM

Hmmm... If you comment out all the code in the load event what happens? I don't see anything in the load code that should stop the form from showing.
Was This Post Helpful? 0
  • +
  • -

#15 dirigible  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 02-October 08

Re: main form gone AWOL

Posted 03 October 2008 - 09:27 AM

View Postmagicmonkey, on 3 Oct, 2008 - 09:14 AM, said:

Hmmm... If you comment out all the code in the load event what happens? I don't see anything in the load code that should stop the form from showing.

It worked! The form displayed! :)
So... there's something in this section that's stopping it from displaying...
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2