Solved

Creating Dos app with VB

Posted on 2002-07-09
11
165 Views
Last Modified: 2010-05-02
I am creating a Dos Program to make use of some of VBs objects, and am trying to error check it and send a text message to standard out.

Why will print not work in this case?  It is a simple program, and will run without the print statement.

Sub Main()
   Dim strArgs() As String
   
   Dim fName As String
   Dim newName As String
   
   strArgs = Split(Command$, " ")
   
   If strArgs(0) = "" Then
     Print "Error Message"
     
   fName = LCase(strArgs(0))
   newName = LCase(strArgs(1))
     
End Sub

The examples i have seen, the Print command is used like that.

Thanks,

Masterofhisdomain
0
Comment
Question by:masterofhisdomain
11 Comments
 
LVL 22

Expert Comment

by:rspahitz
ID: 7141808
The "Windows" print command requires a reference object, like a printer, form, or picturebox.

You may instead want to use MsgBox instead of Print in the above case.
0
 

Author Comment

by:masterofhisdomain
ID: 7141826
It will be uses as a DOS program, no GUI at all, i wish it were an option.

I just want to send the output to standard out,

if there was some way to do

Print(STDIO,"Error Message")

That is really all i am trying to accomplish, surely this can't be too hard, but beginning to wonder.

Masterofhisdomain
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7141842
Maybe .net deals with that better.  VB6 doesn't really like the DOS window.  It can use SendKeys to Windows-compliant screens, but the DOS window isn't.  Let me give time for oher experts to respond.  I've seen this done before with API calls but don't have the code handy.
0
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 22

Expert Comment

by:rspahitz
ID: 7141854
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 50 total points
ID: 7141856
This is for a new console window:

http://msdn.microsoft.com/code/default.asp?URL=/code/sample.asp?url=/msdn-files/026/000/112/msdncompositedoc.xml

TimCottee has some code that converts a GUI exe into a Console exe by fiddling with the executable header.  That's all you can do in VB because console programs are not supported in version 6.  VB.NET allows console programs as a native project type.
0
 

Author Comment

by:masterofhisdomain
ID: 7141862
It will be uses as a DOS program, no GUI at all, i wish it were an option.

I just want to send the output to standard out,

if there was some way to do

Print(STDIO,"Error Message")

That is really all i am trying to accomplish, surely this can't be too hard, but beginning to wonder.

Masterofhisdomain
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 7141863
"Writing a Console App in Visual Basic"
http://www.montgomerysoftware.com/default.asp?PageID=59
0
 

Author Comment

by:masterofhisdomain
ID: 7141873
It will be uses as a DOS program, no GUI at all, i wish it were an option.

I just want to send the output to standard out,

if there was some way to do

Print(STDIO,"Error Message")

That is really all i am trying to accomplish, surely this can't be too hard, but beginning to wonder.

Masterofhisdomain
0
 

Author Comment

by:masterofhisdomain
ID: 7141876
Sorry about the multiple posts, it seems when you refresh this page it posts.

0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7141898
>when you refresh this page it posts

Yes...at the top of the thread, you'll find a "Reload Question" link which will refresh without a re-post.

--
Another question:
Aer you running an existing DOS app which does not have source code?  If you have the source code, you can probably just drop it into a VB module and do everything from VB!
0
 

Author Comment

by:masterofhisdomain
ID: 7141911
This was what led to my final solution although not one i can say that i like.  It is just the output portion of what you provided.


I found this page, http://nirsoft.tripod.com/vb/console.html

So i guess i will use what i found, until we upgrade to .net or a better solution is found.

Thanks all for the help.

Masterofhisdomain
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

776 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