user2874682 user2874682 - 4 months ago 18
Vb.net Question

How to Open console in VB

I currently have a

console application
by using the setting illustrated in the image bellow. However Now I wish to open multiple forms with the
console
so I'm wondering if I can somehow open multiple forms or open the
console
within a
Windows Forms Application


Here is the Project's settings

Answer

@tinstaafl can you share this extra programming or a link to a solution. Thanks

Here's a couple of links:

Console and WinForm together for easy debugging

Console Enhancements

Here's a conversion of the first one. You'll need a form with a checkbox name "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

Everytime you click the checkbox you show or hide the console. You can write to and read from the same as any console app.

Comments