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
Solved

Creating Dos app with VB

Posted on 2002-07-09
11
166 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VBA Shell can't Find Word document 11 112
how to know if my Checkbox is True in VB6.0? 9 60
Zip Folders Using Chilkat Routines 1 58
Automatic Email Reminder 4 58
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

828 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