|
-
Sep 3rd, 2002, 06:22 PM
#1
Thread Starter
Junior Member
Starting form from Sub Main
Ok I have an app and I want to be able to execute from command line and from GUI.
I created a sub main
Code:
Public Shared Sub main()
Dim args As String() = Environment.GetCommandLineArgs()
Dim arg As String
If args.GetUpperBound(0) = 0 Then
' load user interaction form
Dim f As New frmNetStat()
f.FormLoad()
Else
frmNetStat.GetCommandLineArgs()
' process arguments
' no visual display is necessary
End If
End Sub
Public Sub FormLoad()
lblStatus.Text = "Awaiting command..."
g_strConnection = "connection info..."
' form shows up and then exits immediately
Me.Show()
End Sub
however, the problem is it pops up the form and disappears w/o any type of input from the user 
My sub main procedure is placed just below the
Public Sub New proc...
public sub form load is in the main part of the code
I did change the startup to be Sub Main and not the standard formload.
Any ideas
Last edited by El-Phantasmo; Sep 3rd, 2002 at 06:44 PM.
-
Sep 3rd, 2002, 07:26 PM
#2
Try using the Application.Run method like this:
VB Code:
Public Shared Sub main()
Dim args As String() = Environment.GetCommandLineArgs()
Dim arg As String
If args.GetUpperBound(0) = 0 Then
' load user interaction form
[b]Application.Run(New frmNetStat())[/b]
Else
frmNetStat.GetCommandLineArgs()
' process arguments
' no visual display is necessary
End If
End Sub
Public Sub FormLoad()
lblStatus.Text = "Awaiting command..."
g_strConnection = "connection info..."
' form shows up and then exits immediately
Me.Show()
End Sub
You can get more info on the method in the help. Also you should just use the Form_Load event or call your FormLoad method from the Form's constructor.
-
Sep 3rd, 2002, 07:53 PM
#3
Thread Starter
Junior Member
ahhh that worked great 
Thanks!
I'll read up some more on that application.run
-
Sep 4th, 2002, 05:56 PM
#4
Thread Starter
Junior Member
ok.. new problem.
I can't get console.writeline("some string") to actually output to console.
I understand writeline writes to the standardoutput.
I tried to set it with
System.Console.SetOut(Console.Out)
however, that didn't do a thing 
The GUI pops up fine when I don't have any parameters as it should, and it works great from command line.. but I can't get it to output text to command line.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|