Solved

Creating Dos app with VB

Posted on 2002-07-09
11
163 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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now