?
Solved

Creating Dos app with VB

Posted on 2002-07-09
11
Medium Priority
?
170 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
[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
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
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.

 
LVL 22

Expert Comment

by:rspahitz
ID: 7141854
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 200 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month11 days, 12 hours left to enroll

752 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