Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB Console Application

Posted on 1999-07-11
9
Medium Priority
?
273 Views
Last Modified: 2010-05-02
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 ?
0
Comment
Question by:stewa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
9 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1523520
The easiest way is just to communicate with stdout and stdin.
Here is a sample of a VB application that does this
http://www.reohr.com/intelligence/papers/vbsolutions.html 

0
 

Author Comment

by:stewa
ID: 1523521
Sorry the Link doesn't work.
I can get stdout to work using ">" but I cannot get it to display on the console
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1523522
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:stewa
ID: 1523523
I am already using cgi4vb, have you managed to get it to output directly to the Console ?
0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 600 total points
ID: 1523525
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  

0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1523526
You won't see the output I think in the console.
Update problem
0
 

Author Comment

by:stewa
ID: 1523527
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.


0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1523528
Sure email it. See my profile.

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question