Console.Write Not Working In Win Forms App

前端 未结 7 1291
走了就别回头了
走了就别回头了 2021-01-12 05:08

I created a VB.NET Windows Forms Application in Visual Studio 2008. When I run my program from the command-line, I get no output (only the next prompt).

What am I d

7条回答
  •  忘掉有多难
    2021-01-12 05:24

    The others are correct in saying that you need to run your app as a console app. To your question of whether you can have both a console and a GUI: yes. Simply add a reference to System.Windows.Forms to your project, and for the app's Main method, include this code:

    ' here instantiate whatever form you want to be your main form '
    Dim f As New Form1
    
    ' this will start the GUI loop, which will not progress past '
    ' this point until your form is closed '
    System.Windows.Forms.Application.Run(f)
    

提交回复
热议问题