By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,956 Members | 1,683 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,956 IT Pros & Developers. It's quick & easy.

Sub Main not being executed in complied program

P: 2
Hi there,

I've written a Programm which shall be started with or without Parameters. Without Parameters, a setup-form is loaded, with Parameters, a FTP-Transfer-form is loaded. I've included a Sub main-procedure and deactivated the Framework and everything works fine but only within the IDE. If I start the compiled exe-file, the Sub main is noz executed.
Here's the code:
Expand|Select|Wrap|Line Numbers
  1. Public Sub Main()
  2.         Dim lDoSetup As Boolean = False
  3.         Dim aCom As String() = Environment.GetCommandLineArgs
  4.         If aCom.Length > 0 Then
  5.             If aCom.Length = 1 Then
  6.                 If Debugger.IsAttached Then
  7.                     lDoSetup = True
  8.                 End If
  9.             End If
  10.         Else
  11.             lDoSetup = True
  12.         End If
  14.         If lDoSetup Then
  15.             MsgBox("Setup ist True")
  16.         End If
  18.         If lDoSetup Then
  19.             Application.Run(New SetupFRM)
  20.         Else
  21.             Application.Run(New FTPFRM(aCom))
  22.         End If
  23.     End Sub
so when called without Parameters, SetupFRM should be loaded but isn't. So it seems that this code is not executed but FTPFRM loaded when the exe is started(I forgot to mention above, that Sub main is selected as start-object)
Hay anybody any idea what might cause this.

Best regards

Jan 20 '16 #1
Share this Question
Share on Google+
1 Reply

P: 2
Problem is solved. There are two Errors:

1. Msgbox is not being shown. I use
2. There is always a first commandline-arg containig the program-Name. So the setup-form has never been called.

Best regards

Jan 20 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.