VB Console Application

I am trying to write a VB application that can send output back to the Console that called it. i.e. I am trying to write a command line style program. I have tried using the ApiCall WriteFile but the output seems to go down a hole. Any ideas ?
Who is Participating?
MirkwoodConnect With a Mentor Commented:
Option Explicit

   Declare Function AllocConsole Lib "kernel32" () As Long
   Declare Function FreeConsole Lib "kernel32" () As Long
   Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) _
           As Long
   Declare Function GetStdHandle Lib "kernel32" (ByVal _
           nStdHandle As Long) As Long
   Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" _
           (ByVal hConsoleOutput As Long, lpBuffer As Any, ByVal _
           nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long, _
           lpReserved As Any) As Long

   Public Const STD_OUTPUT_HANDLE = -11&

Sub Main()

Dim hConsole As Long

Dim a

   Dim Result As Long, sOut As String, cWritten As Long
  a = AllocConsole()
       hConsole = GetStdHandle(STD_OUTPUT_HANDLE)
     sOut = "Hi There dsfkj kdsfkjldfs kjdfslj kldsf jk" & vbCrLf
     Result = WriteConsole(hConsole, ByVal sOut, Len(sOut), cWritten, _
                           ByVal 0&)
End Sub  

The easiest way is just to communicate with stdout and stdin.
Here is a sample of a VB application that does this

stewaAuthor Commented:
Sorry the Link doesn't work.
I can get stdout to work using ">" but I cannot get it to display on the console
7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

stewaAuthor Commented:
I am already using cgi4vb, have you managed to get it to output directly to the Console ?
You won't see the output I think in the console.
Update problem
stewaAuthor Commented:
Thanks for your response.

I the end I obtained some software/code from www.devx.com which alters the EXE header from Gui to Console App.

If you could make use of this code then I can e-mail it to you.

Sure email it. See my profile.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.