我目前有一个console application
使用下图所示的设置。但是现在我希望使用 console
打开多个表单所以我想知道是否可以以某种方式打开多个表单或打开 console
在Windows Forms Application
内
最佳答案
@tinstaafl can you share this extra programming or a link to a solution. Thanks
这里有几个链接:
Console and WinForm together for easy debugging
这是第一个的转换。您需要一个复选框名称为“CheckBox1”的表单:
Imports System.Runtime.InteropServices
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
If CheckBox1.Checked Then
Win32.AllocConsole()
Console.WriteLine("Done!")
Else
Win32.FreeConsole()
End If
End Sub
End Class
Public Class Win32
<DllImport("kernel32.dll")> Public Shared Function AllocConsole() As Boolean
End Function
<DllImport("kernel32.dll")> Public Shared Function FreeConsole() As Boolean
End Function
End Class
每次单击该复选框时,您都会显示或隐藏控制台。您可以像任何控制台应用程序一样写入和读取。
关于vb.net - 如何在VB中打开控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21055166/