Convert existing vb console ap to windows form

Posted on 2010-01-07
Last Modified: 2012-05-08
I have a existing console ap and have been asked to convert it to a windows form with no form so that it runs in the background.  Most of what I've seen out there is how to convert a C,C++ or C# console ap to windows form, but I don't program in those languages so they don't help me.  I need a VB solution for this.  What refrences do I need to add to the thing to make it run in the back ground.  If there is a way to keep it a console app but run in the background, I'll take that too.
This is being run on Windows XP and Visual Studio 2008/2005.
Question by:Kakoroat
    LVL 42

    Expert Comment

    u can keep it as a console but hide it using ShowWindow API:

            public extern static bool ShowWindow(
                IntPtr hWnd,
                int nCmdShow);
            static void Main(string[] args)
                ShowWindow(Process.GetCurrentProcess().MainWindowHandle, 0);
    LVL 42

    Expert Comment

    sorry, didn't see u need
    <DllImport("user32.dll")> _
    Public Shared Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Boolean
    End Function
    Private Shared Sub Main(ByVal args As String())
        ShowWindow(Process.GetCurrentProcess().MainWindowHandle, 0)
    End Sub

    Open in new window

    LVL 69

    Expert Comment

    by:Éric Moreau
    >>I  have a existing console ap and have been asked to convert it to a windows form with no form so that it runs in the background.

    What do you mean exactly? What kind of application is it? Do you mean a service?

    A console application or a Windows Forms with no visible forms does exactly the same thing.


    Accepted Solution

    It was built as a console application and is run by the scheduling service on the server.

    Regardless, a cooworker pointed out the easiest answer to the problem.  Under My Project --> Application --> Application type
    I changed it from  Console Application to Windows Forms Application
    So essentially, it is a Windows Form application with no form.
    I built it and then ran it through the scheduling service and there was no extra window opened (basically problem solved).

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now