vbAdvance Console Addin for VB6

Posted On 2018-03-10 by VB6Boy
Tags: VB6 Miscellaneous VB6 Windows API VB6 Custom Functions 
Views: 98

Title Uploaded Size
vbAdvance.chm 3/10/2018 12:45:18 PM 203,430
vbAdvance3_1.exe 3/10/2018 12:42:09 PM 866,867

vbAdvance is a Visual Basic Add-In that gives you access to advanced build features and many IDE convenience features.

As a Visual Basic Add-In, vbAdvance runs while you design and compile your applications. Once your app is built, vbAdvance is no longer needed. vbAdvance adds no distributable dependencies to your projects - there is nothing to distribute because vbAdvance is only needed by the VB IDE.

vbAdvance is a fast, efficient and groundbreaking piece of work, providing access to many features that are otherwise not possible in VB. Read on for the full list of features.

Copyright Young Dynamic Software

VBAdvance remains ©2001-2007 Young Dynamic Software. All rights reserved. The content of the original website has been preserved here in the event the original page disappears. This "mirror" has been set up in order preserve a valuable resource for the benefit of the community.

In no way, shape, or form do I or this site claim any authorship of this post. All the credit goes to Karl E. Peterson (now retired, I think) and Young Dynamic Software (no longer in business).

Build Features

vbAdvance gives Visual Basic powerful new abilities.

Console Applications

Create true console-subsystem applications in Visual Basic that interact with the command-prompt from which they were launched. We are proud to be able to include a uniquely powerful Console Support Code Module and samples courtesy of Karl E. Peterson (author of the "Ask the VB Pro" column in Visual Basic Programmer's Journal and a VB MVP). This code module is the only one of it's kind and provides everything you'll need to create full-featured and robust console applications.

Function Exports

Build standard DLLs that export functions using Visual Basic. Function exports are required for certain application types such as Control Panel Applets. Having access to this feature allows you to build these applications using VB. You can also implement the DllInstall feature of RegSvr32.exe in your DLLs to provide command-line switch customized registration of your DLLs. Many application plug-ins, such as WinAmp and InstallShield plug-ins, require function exports, which means you can now use Visual Basic to create them instead of having to resort to another language, or rely on non-VB proxy DLLs and the troubles that go with them.

Complete Version Number Control

Visual Basic inexplicably omits one of the fields in your application's version number resource. The version number standard is as follows:


What VB normally gives you is this:


In other words, the Revision field is always set to 0. To confuse matters further, what VB calls the Revision field is actually the Build field. Be confused and frustrated no longer - vbAdvance gives you full access to your application's version fields.


The DllMain entrypoint is used in standard DLLs as a way to recieve startup and teardown notification. vbAdvance gives you the ability to use a DllMain entrypoint in your standard DLLs.

DllRegisterServer / DllUnregisterServer customization

An extension of the Function Exports feature, the ability to override and customize these two registration exports gives you full control over your DLL's registration. For example, starting with Windows 2000, you have the option to register an ActiveX DLL to HKEY_CURRENT_USER instead of HKEY_LOCAL_MACHINE, thus avoiding the permissions problems some customers face. Unfortunately, VB gives you no way to specify this change. vbAdvance does. Using vbAdvance, you can easily change the Registry hive your DLL or OCX is registered under. You could also easily add any custom code you wanted to run at registration time.

XP Manifest Resource Compiler

This option allows you to very easily add support for the new XP Themes. It automatically compiles the necessary XP Manifest Resource into your application. This feature eliminates the need to distribute a seperate XML file with your application and the trouble that goes along with it.

Terminal Server Aware Applications

Create applications that are Terminal Server Aware, giving you full control over your app's behavior when run in a Terminal Server environment.

App Icons

Set your application icon without the need for a Form or a Resource file. Just point to the icon file and build your project.

Advanced Debug File Options

Strip private information from your PDB debug files to prevent reverse-engineering of your app when distributing debug files. Compile the Symbolic Debug Information into your EXE or DLL and avoid having to distribute a seperate PDB file. Generate MAP and DBG files for your project. With vbAdvance, the full list of possible debug file generation options is made available to you.

Resource-Only DLLs

Build a resource-only DLL from your project's resource file with the touch of a button.

Dynamic Conditional Compile Arguments

Specify conditional compile argument values that differ between design time and compile time. This is particularily useful for the DbgWProc.dll constant, DEBUGWINDOWPROC, which must be set to 1 when in design mode and 0 when compiled. Another example would be an IN_IDE conditional to determine if you're running in design mode, or compiled.

Custom DOS Stub EXEs

VB automatically creates a DOS stub EXE for you when you build an executable. The purpose for this is to output some text to the command line when your EXE is run from the DOS environment, explaining that it is a Windows app and will not run under DOS. The Custom DOS Stub EXE feature allows you to place your own DOS stub EXE into your app, allowing you to customize the text that is displayed or even to run an actual DOS version of your application.

IDE Enhancements

vbAdvance makes the Visual Basic IDE better and easier to use.

Check Syntax

Check for syntax errors without building your binary.

Build Button

Very similar to the Visual C++ Build button, this builds your project immediately. No dialogs are presented after the first build of the project sets the build path.

Execute Button

Very similar to the Visual C++ Execute button, this launches your compiled app. A Send Command Line Args option allows you to send your project's command-line arguments to the executable.

Send Code Module to Text Editor

VB's code editor is decent, but not great. If it weren't for Intellisense, there'd be nothing special about VB's integrated code editor. For high-powered editing, many programmer's turn to a professional text editor. vbAdvance makes it trivial to send the current code module to your text editor. Just press the button and your editor will open with the code module you were just viewing from VB. And when you've made your changes and return to VB, vbAdvance's Detect Code Module Changes feature will detect your edits and reload the module for you.

Detect Code Module changes outside of IDE

This feature enables VB to detect when any code modules in your project are changed by another process. For example, if you Get Latest from SourceSafe, and one of your code modules is overwritten with a newer version, or if you edit one of the modules with a text editor, or even if you copy over a module using Windows Explorer, this feature will notify you that there was a change and offer to reload the module automatically, saving you from having to reload the entire project in order to pick up the changes.

Disable Build Dialogs

The first time you build your project, you are presented with a 'Save As...' style dialog to tell VB where you want to build your project and what you want it named. This makes perfect sense. What doesn't make sense is that even though you already told VB what to name the executable, VB keeps asking you the same question every time you build your project - and to make matters worse, it kindly tells you that there's already a file of that name (duh!) and do you want to overwrite it? Well, vbAdvance to the rescue! The Disable Build Dialogs feature prevents those dialogs from appearing once you've told VB where to build the project. The first time you'll be asked where to build it, and subsequent times you will not be bothered. This is the normal behavior of the vbAdvance Build button, this feature allows you to apply it when building from the File menu option.

Clear Immediate Window

This feature automatically clears the Immediate Window when you run your project.

Sizeable Dialogs in the IDE

Ever wonder why all of the standard Windows common dialogs used by the VB IDE are not sizeable? So did we, and we took care of the problem. When vbAdvance is running, all standard Open and Save dialogs are sizeable.

Binary Compatibility File Enhancement

An extension of the sizeable dialogs feature is found when you select your Binary Compatibility file for an ActiveX DLL project. It has become standard practice to use an extension of *.cmp for compatibility files in order to avoid confusion with the target DLL. Unfortunately, VB's Open dialog requires a few clicks to change the Selection Filter to 'All Files' in order to see any *.cmp files. vbAdvance adds the *.cmp filter entry to this Open dialog and makes it the default selection.

Alert/Clear of Read-Only attribute when building or saving

Ever make a change to a source file, only to find you can't save it because it's marked read-only? Or try to build your project and can't, again because the target binary is read-only? vbAdvance adds intelligence to VB, alerting you of the problem and offering to clear the read-only flag for you, so you can get on with your work, instead of wasting time in Windows Explorer.


vbAdvance is now unsupported freeware. Use the following license to register the product:


Copy it all (include the BEGIN and END LICENSE lines). In the Advanced Options dialog, click on the "About" button, then click on the "Register" button. Paste your registration info and click OK.

You can download the last and latest version of vbAdvance at the top of this page. Also available is help file, in stand-alone .chm format. Note that the help file is also included with the full installation.

Console sample code is shown below. Note: This console code is already included in the vbAdvance installation package, and the latest code is included at the time of packaging. Note however, that Karl Peterson may have updated the code since then. You may follow this link to ensure you have the latest version.


Run the self-extracting executable and follow its instructions. Once installed, the add-in will load automatically the next time you start VB. The vbAdvance Toolbar will be floating in the center of the screen and may be repositioned and docked to your liking.

The vbAdvance Help File is accessible from the Start menu if you chose to install the icons. You can also access the online Help from the vbAdvance Advanced Options dialog, which can be launched from the vbAdvance Toolbar or the VB Add-Ins menu.

Special Instructions

The whole enchilada. If you want to write a real console application, using Classic VB, this is the ticket. Create a new project, set it to start with Sub Main, drop the MConsole.bas file into your application, and you're almost ready to rock. This sample provides complete support for writing and testing console applications within the IDE.

MConsole is designed as a lightweight COM object, using techniques developed by Matt Curland, and published in his book Advanced Visual Basic 6. This means you only need to initialize the object, and from there it handles teardown itself at application completion. The lightweight console object creates its own console window for output to while running within the IDE, which eliminates the need to compile before each test, and makes interactive debugging a possibility for the first time.

All the standard output functionalities you would expect are available. In this little example, you can see how easy it is to initialize the console, and start writing to it. This snippet even changes the background and foreground colors, as well as the command window caption:

Public Sub Main()
   Dim sName As String
   Dim fColor As Long, bColor As Long
   Dim sCaption As String

   ' Required in all MConsole.bas supported apps!

   ' Stash value(s) we'll later reset.
   bColor = Con.BackColor
   fColor = Con.ForeColor
   sCaption = Con.Title

   ' Read and write a simple response:
   If Con.Height < 50 Then Con.Height = 50
   Con.ForeColor = conGreenHi
   Con.WriteLine "What's your name? ", False
   Con.ForeColor = fColor
   sName = Con.ReadLine()
   Con.ForeColor = conGreenHi
   Con.WriteLine "Hello " & sName, False
   Con.Title = "Console Demo for " & sName

   ' Restore original console colors and caption.
   Con.BackColor = bColor
   Con.ForeColor = fColor
   Con.Title = sCaption
End Sub

Of course, redirection and pipes are fully supported as well. Here's a snippet showing how to read standard input, and send it directly to the clipboard. This snippet also demonstrates output of debugging information, output to standard error, and the issuance of an exitcode upon completion:

Public Sub Main()
   Dim sData As String
   Dim sMessage As String

   ' Required in all MConsole.bas supported apps!

   ' Check to see if we have any waiting input.
   If Con.Piped Then
      ' Slurp it all in a single stream.
      sData = Con.ReadStream()
      ' Just to prove we did it, place text on clipboard.
      Clipboard.SetText sData
      ' Write some debugging information.
      Con.DebugOutput "Wrote " & CStr(Len(sData)) & _
         " characters to clipboard."
      sMessage = "No redirection detected; nothing to read?"
      ' Send error condition to Standard Error!
      Con.WriteLine sMessage, True, conStandardError
      Con.DebugOutput sMessage
      ' Set an exit code appropriate to this error.
      ' Application MUST BE COMPILED TO NATIVE CODE to
      ' avoid a GPF in the runtime!!!
      Con.ExitCode = 1
   End If
End Sub

There sample is probably one of the most comprehensive available on this site. There are uncountable uses for it, as it covers just about every conceivable aspect of console application authoring.

Required Modification of Executable

The only difference between a console application and a windowed application, is a single bit in the Portable Executable (PE) file header which is set during the compilation process. Classic VB doesn't natively support setting this PE attribute. There are several easy ways to to approach this limitation. The oldest method, first published by L.J. Johnson, is to toggle a bit in the PE header of your executable following compilation. This alerts Windows to start it up as a console, rather than windowed, application. The extra step can be a real hassle, though. Matt Curland's book, referenced above, includes a free add-in that modifies the flags passed to the compiler, so that it produces a console application for you. My favorite though, which offers the same capability, is to use the vbAdvance add-in, which offers many other unique capabilities in addition to this vital one.

Another option is to post-process the EXE, immediately after compilation. Bob Riemersma has offered a short VBS script that makes this process incredibly simple. Just copy this text to a file named LinkConsole.vbs either on your desktop or in the project directory:


' LinkConsole.vbs
' http://www.angelfire.com/mi4/bvo/vb/vbconio.htm
' This is a WSH script used to make it easier to edit
' a compiled VB6 EXE using LINK.EXE to create a console
' mode program.
' Drag the EXE's icon onto the icon for this file (or onto
' a shortcut to this file), or execute it from a command
' prompt as in:
' LinkConsole.vbs Project1.exe
Option Explicit

Dim strLINK, strEXE, WSHShell

' Be sure to set up strLINK to match your VB6 installation.
strLINK = """C:\Program Files\Microsoft Visual Studio\VB98\LINK.EXE"""

strEXE = """" & WScript.Arguments(0) & """"

Set WSHShell = CreateObject("WScript.Shell")


Set WSHShell = Nothing
WScript.Echo "Complete!"


Then, after compiling your project, drag the resulting EXE and drop it on the VBS (or a shortcut to it). All done. Your EXE is now set to run within the console subsystem. (Be sure to edit the path to LINK.EXE if you installed VB6 to a nonstandard location.)

Lightweight Console Object Methods

Initialize Must be the first method called. Creates the lightweight object, which is used for automated tear down support. Determines the initial state of numerous other properties, and obtains standard IO handles for input, output, and error.
DebugOutput Writes debugging information to both the Immediate window and through a call to OutputDebugString so that it can be read even in a compiled application. 
FlashWindow Flashes console window titlebar and taskbar icon to get users attention.
Flush Flushes the console input buffer of any waiting input records.
ReadChar Reads a single character of user input, without displaying it, and immediately returns.
ReadLine Reads one line of input from user. Optionally writes prompt to screen.
ReadPassword Obscures user input behind a specified password character.
ReadStream Reads all available input records.
Resize Sets new height and width values for console text buffer.
PressAnyKey Prompts the user to "press any key" to continue, and waits for them to do so.
SetFocus Sets focus, optionally with force, to the console window.
ShowCursor Toggles visibility of console cursor, in an identical manner to that of the ShowCursor API.
WaitingInput Signals that input records are waiting to be read.
WriteLine Writes a line of text  to either standard output or standard error. Optional alignment support offered.

Lightweight Console Object Properties

BackColor Background color used for new console output.
Break Flag value that indicates the user has attempted to manually break execution of the console application, by pressing Control-C or similar. See: ControlEvent property.
BufferHeight Height of text buffer, in lines, for current console.
BufferWidth Width of text buffer, in characters, for current console.
CodePage Codepage of current console.
ControlEvent Read-only: Indicates what sort of event occurred that requires the application to shutdown. Possibilities include Control-C, Control-Break, Close [X], Logoff, and Shutdown. See: Break property
Compiled Read-only: Flags whether the application is compiled or running in the IDE.
CurrentX X position for next output.
CurrentY Y position for next output.
CursorHeight Height of cursor, in scan lines.
CursorVisible Current state of cursor visibility.
ExitCode Exitcode to emit when process completes.
ForeColor Foregoundcolor used for new console output.
FullScreen Toggles between full-screen and windowed mode, or indicates current status.
Height Height of current console, in lines.
hStdErr Read-only: Handle to standard error.
hStdIn Read-only: Handle to standard input.
hStdOut Read-only: Handle to standard output.
hWnd Read-only: Handle to console window.
LaunchMode Read-only: Indicates whether the application was launched from within the IDE, directly from the command line, or from Explorer via a shortcut or double-click.
ParentFilename Read-only: Returns the filename of the process that launched the application.
ParentProcessID Read-only: Returns the process ID of the process that launched the application.
Piped Read-only: Indicates whether piped or redirected input is waiting to be read from standard input. Test this value just once, at application initialization, to determine whether to proceed as a filter or interactively.
Redirected Read-only: Indicates whether standard output from this application has been redirected.
TaskVisible Current visibility of task, including whether it can be seen as a separate application within Task Manager.
Title Caption of console window.
Visible Visibility of console window.
Width Width of current console, in characters.
WindowState Normal, minimized, or maximized.

APIs Usage

The included samples use the following API calls:

Module Library Function
Demo-Codepage.bas kernel32 Sleep
Demo-EnvChange.bas advapi32
Demo-ExitCode.bas kernel32 Sleep
Demo-Interactive.bas kernel32 Sleep
Demo-Parent.bas kernel32 Sleep
MConsole.bas kernel32
MEnvVars.bas advapi32

Copyright Young Dynamic Software

VBAdvance remains ©2001-2007 Young Dynamic Software. All rights reserved. The content of the original website has been preserved here in the event the original page disappears. This "mirror" has been set up in order preserve a valuable resource for the benefit of the community.

In no way, shape, or form do I or this site claim any authorship of this post. All the credit goes to Karl E. Peterson (now retired, I think) and Young Dynamic Software (no longer in business).


Visual Basic 5 or Visual Basic 6 Professional or Enterprise Editions, Service Pack 3 or higher. Win 98, 2K, XP.

About the Author

has posted a total of 101 articles.

Comments On This Post

By: dwirch
Date: 2018-03-10

Webmasters Note

I attempted to contact Karl Peterson, Young Dynamic Software, and the webmaster of mvps.org, with no success.

I have approved the posting of this content on the basis that the persons or entities listed have no further interest in the content, as well as the copyrights appear to have been updated since at least 2007 for the content, or 2011 for mvps.org.

If any of the people or entities listed above have questions, comments or concerns with this post, please don't hesitate to use the contact form in the footer below to get ahold of me.

Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.

Your IP address is:

Before you can post, you need to prove you are human. If you log in, this test goes away.

Code Links