Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
VB.Net Express 2008. Windows forms application. Application frame work disabled.

Following is my code:

Module Module1

Sub main()

Dim frm1 As New Form1


frm1.Show()

Dim xl As Microsoft.Office.Interop.Excel.Application

xl = CreateObject("Excel.Application")

xl.Visible = True

frm1.Hide()

End Sub

End Module

I want to show a Wait message while Excel is being opened.

The form does not show properly. All the labels and text boxes show as 'holes' displaying the desktop instead of text inside it.
Posted

1 solution

Since you're runnint from Main instead of letting the framework do it, you have to launch the form differntly to setup the app's message pump.

Instead of Form.Show, you do this:
Dim frm1 As New Form1
Application.Run(frm1)


Application.Run is a blocking call, so no code after it will execute until the form is closed.
 
Share this answer
 
Comments
SanganakSakha 6-Mar-12 16:16pm    
That's exactly I don't want to do - block the following code.

I want to display a Wait message (using the form) until Excel is opened and hide it as soon as Excel is opened. So I want Excel to open while the message is being displsyed.

I could do it without any problem in VB6 with simple frm1.show as against frm1.show(vbModal).
Dave Kreskowiak 6-Mar-12 17:06pm    
OK, so scrap this. If all you're doing is starting Excel with a "please wait" dialog over it you can do that quite easily.

Start a new project and in the start up Form, put a button. This button will start Excel but only after it creates an instance of the "Please Wait..." form and Show it.

Private Sub Start_Button(...) Handles StartButton.Click
Dim waitForm As New PleaseWaitForm
waitForm.Show


' I can't believe I'm doing this!
Application.DoEvents()


Dim xl As Microsoft.Office.Interop.Excel.Application

xl = CreateObject("Excel.Application")
xl.Visible = True

waitForm.Hide()
End Sub
SanganakSakha 6-Mar-12 18:16pm    
I'm sorry but starting Excel is not the main activity in my program.

I do lot of of processing before opening Excel. I then open Excel and and then do lot of processing. I'm doing all this inside the main().

I just want to display a message to keep the user engaged while user waits for excel to open in the background(invisible). I don't necessarily want to use a form if there is any other alternative available.

I thought, using a non-modal form would be very simple. It doesn't seem to be so.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900