I found a script works and copy here, i worry i don't know where to found this again someday:
Option Compare Binary
Option Explicit On
Option Infer Off
Option Strict On
Imports System
Public Class Form1
Private Declare Function AllocConsole Lib "Kernel32.dll" () As Integer
Private Declare Function GetStdHandle Lib "Kernel32.dll" (ByVal nStdHandle As Integer) As Integer
Private Declare Function WriteConsoleA Lib "Kernel32.dll" (ByVal hConsoleOutput As Integer, ByVal lpBuffer As String, ByVal nNumberOfCharsToWrite As Integer, lpNumberOfCharsWritten As Integer, lpReserved As Integer) As Integer
Private Const STD_OUTPUT_HANDLE As Long = -11
Private Sub Form1_DoubleClick(sender As Object, e As EventArgs) Handles MyBase.DoubleClick
AllocConsole()
Dim OutputHandle As Integer = GetStdHandle(STD_OUTPUT_HANDLE)
Dim Text As String = "test"
WriteConsoleA(OutputHandle, Text, Text.Length, 0, 0)
End Sub
End Class
Beware the text highlighted with yellow text, if you use the keyword "WriteConsole" would got "EntryPointNotFoundException was unhanded" error
Reference:
https://www.vbforums.com/showthread.php?888189-Console-from-Winform-App-not-writing-lines
No comments :
Post a Comment