trying to start a form, from a MAIN sub in a module 
Author Message
 trying to start a form, from a MAIN sub in a module

Hi,

I use VB net.

I just try to start a form that i've created with VB gui :
    Public Class frmPacketeer
    Inherits System.Windows.Forms.Form

When I use "start up object" equal to frmPacketeer eall working fine. My
FORM start and I use my PGM.

What I want to do is have the same program work in command line mode or in
windows form mode.

So I add a MAIN SUB, in a new module called MAIN:
    Module Main
    Public Const

In the main sub, I check if args are pass.
If i have no args then ALL is executed without any forms.

If i get ARGS, then I when to start the form  : frmPacketeer

If i Here my main sub :
Sub main()
Dim args() As String
Dim myForm As New frmPacketeer()
args = GetCommandLineArgs()
If Trim(LCase(args(0))) = "start" Then
    myForm.Show()
Else
    MyDate = Today
    genHTML(CInt(MyDate.Year), CInt(MyDate.Month))
End If
End Sub

What happen is, when I pass arg "START" to my program, then he show the form
really fast then the form disapear and the program stop. Why my form is not
show so i can use it?



Tue, 28 Jun 2005 03:58:13 GMT  
 trying to start a form, from a MAIN sub in a module
Try myForm.ShowDialog()

HTH,
Paul Kuklinski
Microsoft Developer, VB.Net

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> Hi,

> I use VB net.

> I just try to start a form that i've created with VB gui :
>     Public Class frmPacketeer
>     Inherits System.Windows.Forms.Form

> When I use "start up object" equal to frmPacketeer eall working fine. My
> FORM start and I use my PGM.

> What I want to do is have the same program work in command line mode or in
> windows form mode.

> So I add a MAIN SUB, in a new module called MAIN:
>     Module Main
>     Public Const

> In the main sub, I check if args are pass.
> If i have no args then ALL is executed without any forms.

> If i get ARGS, then I when to start the form  : frmPacketeer

> If i Here my main sub :
> Sub main()
> Dim args() As String
> Dim myForm As New frmPacketeer()
> args = GetCommandLineArgs()
> If Trim(LCase(args(0))) = "start" Then
>     myForm.Show()
> Else
>     MyDate = Today
>     genHTML(CInt(MyDate.Year), CInt(MyDate.Month))
> End If
> End Sub

> What happen is, when I pass arg "START" to my program, then he show the
form
> really fast then the form disapear and the program stop. Why my form is
not
> show so i can use it?



Tue, 28 Jun 2005 04:36:47 GMT  
 trying to start a form, from a MAIN sub in a module
Try launching the form using from Sub Main
Application.Run (new myForm)

HTH

--
Corrado Cavalli [Microsoft MVP]
UGIdotNET - http://www.ugidotnet.org



Tue, 28 Jun 2005 04:41:47 GMT  
 trying to start a form, from a MAIN sub in a module
Ty !
Quote:
>Try myForm.ShowDialog()

this work. i did not try to other solution sorry.



Quote:
> Hi,

> I use VB net.

> I just try to start a form that i've created with VB gui :
>     Public Class frmPacketeer
>     Inherits System.Windows.Forms.Form

> When I use "start up object" equal to frmPacketeer eall working fine. My
> FORM start and I use my PGM.

> What I want to do is have the same program work in command line mode or in
> windows form mode.

> So I add a MAIN SUB, in a new module called MAIN:
>     Module Main
>     Public Const

> In the main sub, I check if args are pass.
> If i have no args then ALL is executed without any forms.

> If i get ARGS, then I when to start the form  : frmPacketeer

> If i Here my main sub :
> Sub main()
> Dim args() As String
> Dim myForm As New frmPacketeer()
> args = GetCommandLineArgs()
> If Trim(LCase(args(0))) = "start" Then
>     myForm.Show()
> Else
>     MyDate = Today
>     genHTML(CInt(MyDate.Year), CInt(MyDate.Month))
> End If
> End Sub

> What happen is, when I pass arg "START" to my program, then he show the
form
> really fast then the form disapear and the program stop. Why my form is
not
> show so i can use it?



Wed, 29 Jun 2005 04:23:53 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. start up form sub main

2. Sub Main() Starting Up A Form

3. Starting a form after Closing Sub Main

4. Try-Catch in the Sub Main

5. sub Main for public modules?

6. Starting in Sub Main...?

7. Unload after starting with Sub Main

8. create main form and Sub Form

9. create Main Form Sub form in VB6

10. Incongruous out of memory error when trying to add a function or sub to a module

11. How to change caption on a sub from text on main form

12. Showing a form from within Sub Main.

 

 
Powered by phpBB® Forum Software