Questions

Form.Show doesn't show controls on the Form

Tags:
+
0 Votes
Locked

Form.Show doesn't show controls on the Form

SanKulPune
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.
  • +
    0 Votes
    TonyReilly

    Hi!

    I came across the same problem a while back and managed to get it to work. The best way is to keep the 2 elements separate. By the looks of it you are writing a console application that launches Excel and you want a windows form application to show while they wait.

    Try creating the windows Form application separately and then calling it through your console app:

    1: In your console application add a reference to System.Windows.Forms.dll (under .Net)

    2: Now add another reference only this time instead of clicking .Net choose "Project" and find you windows form application.

    3:Now alter your code:

    Sub Main()
    Dim frm As New WindowsApplication1.Form1
    frm.ShowDialog()
    frm.Focus()
    Dim xl As Microsoft.Office.Interop.Excel.Application
    xl = CreateObject("Excel.Application")
    xl.Visible = True
    frm.Hide()
    End Sub
    End Module

    See what you think! Worked for me!
    Cheers!

  • +
    0 Votes
    TonyReilly

    Hi!

    I came across the same problem a while back and managed to get it to work. The best way is to keep the 2 elements separate. By the looks of it you are writing a console application that launches Excel and you want a windows form application to show while they wait.

    Try creating the windows Form application separately and then calling it through your console app:

    1: In your console application add a reference to System.Windows.Forms.dll (under .Net)

    2: Now add another reference only this time instead of clicking .Net choose "Project" and find you windows form application.

    3:Now alter your code:

    Sub Main()
    Dim frm As New WindowsApplication1.Form1
    frm.ShowDialog()
    frm.Focus()
    Dim xl As Microsoft.Office.Interop.Excel.Application
    xl = CreateObject("Excel.Application")
    xl.Visible = True
    frm.Hide()
    End Sub
    End Module

    See what you think! Worked for me!
    Cheers!