Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Convert existing vb console ap to windows form

Posted on 2010-01-07
4
Medium Priority
?
406 Views
Last Modified: 2012-05-08
Hello,
I have a existing vb.net 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.
0
Comment
Question by:Kakoroat
  • 2
4 Comments
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 26200745
u can keep it as a console but hide it using ShowWindow API:

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

Expert Comment

by:Meir Rivkin
ID: 26200753
sorry, didn't see u need vb.net:
<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

0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 26200781
>>I  have a existing vb.net 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.

0
 

Accepted Solution

by:
Kakoroat earned 0 total points
ID: 26201971
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).
MyProjectPic.jpg
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses

564 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