vb6 to VB.Net upgrading Sub Main() error

Hi everyone.. thanks for taking a peek on my thread.
Im upgrading a VB6 application. On its sub main, after it finishes, keeps jumping to other control on different forms. Is there a way to make my project to still go through code just the way VB6 does




Answer this question

vb6 to VB.Net upgrading Sub Main() error

  • Shailaja

    Perhaps your easiest solution is to create a form within your main call, and have that form be invisible, and be responsible for creating/calling the other forms as they are needed I'm not sure exactly how your app is architected, but it feels like you need to change your architecture for .NET. What is the entry point for your code, if it's not the main method How did this app stay alive in VB6 ( that is, how did it keep running when the main method ended )



  • Gazelle

    That looks really messy. I would expect that you'd have a central form in your app, that should be created here. When it closes, the app ends. If you create a function that never ends and does nothing, and you expect other code to just run your app, that won't happen. I was more thinking if you have lots of forms that open and close, code in Main would be responsible for switching between those forms.



  • serras

    Creating a endless function will keep the other code working Or I have to create a function that points to other routines

    I got the next code in my main routine

    Public Sub Main()
    ' Quit if the application is already running
    If (UBound(Diagnostics.Process.GetProcessesByName (Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0) = True Then
    AppActivate("VB02_WI_II")

    End
    End If

    VB99_LoadingScreen.DefInstance.Show()
    System.Windows.Forms.Application.DoEvents()
    VB02_Work_Instructor.DefInstance.Show()
    VB02_Work_Instructor.DefInstance.Form_Init()
    VB02_Work_Instructor.DefInstance.Arrows(0,
    False) <. in vb6 after runnnig this code goes to a timer that I got in other form
    End Sub

    VB.Net tells to create a form, and move the sub main code to a load event or call from load the sun main.My Sub main its contained on a module. Honestly I have no idea on how to do it. It sounds logical to create a function that never ends, but Im not sure if all my other events will be raised. Im mixing terms here.. im very lost...



  • smart_saqib143

    Sup everyone..

    I add a form that just calls the sub main of my main form (before adding the new one) and that avoids closing my app when executing the main part and keeps with all the other operations I need. Thanks all for your help.



  • Duke of URL

    I know it does look that way.... all the applications starts on a module, then jumps to main form and from there its starts to instance different methods from other forms. Im not sure on how to handle all instances from one form since each one enters on the program at a specific time. Im really lost here.. thanks for your help chris...



  • n3sachde

    Sup cgraus..
    No.. thats not what I meant. What I tried to say its that in VB6, my application once it finishes the Sub main(), it keeps working with other forms. I understand that in VB6, all forms need to be destroyed so that the application can end. In vb.net after finishing the Sub main, it finishes automatically all the application.

    How can I handle my code in order to keep working after it passes through my main routine



  • Indian Scorpion

    In Vb.NET 2005 you can use the project settings to set the applciation lifetime to either the startup form, which is the default in earlier versions of Vb.NEt and in C#, or to until all forms are closed.

    To take advantage of this applciation framework you'll need ot move your code out of the custom sub main into the application eventss. (you get to the applciation events also from the proejct properties pages)

    Bill



  • Jagjot

    I don't fully understand what you're saying - the UI jumps between different forms by itself



  • Emrys Mydhrin

    Oh, OK. In that case, no. Your main function needs to create a form that exists for the lifetime of the project, or have some other code in there that somehow keeps that one function going until the program ends.



  • David Seifert

    In your Sub Main(), show your form by using Application.Run(frm), it will pause your Sub Main until the form closes.


  • vb6 to VB.Net upgrading Sub Main() error