banner.png (6088 bytes) Don't Click This
These Pages Are Under Review 2021

Home

Last Updated
6th March 2021

Downloads
Installation
Documentation
Function List
Updates and News
Test Program
Differences Between VB5 and 6
Usage Notes
Using VBToolbox to Create Console Programs
Calling VBToolbox from C/C++
SetWall Wallpaper Changer
Using VBToolbox for Server CGI
Visual BASIC 5 and SQLite3
Handling Callbacks in VB/C++
FAQ
Feedback

SQLite and Visual BASIC 5

VBToolbox Online Manual (HTML)
v1.33 Converted using PDFToHTML

VBToolbox Online Manual (HTML)
v1.32 Converted using PDFToHTML

VBToolbox Online Manual (HTML)
v1.31 Converted using PDFToHTML


Downloads

You may need the VB5 runtimes - you can download from Microsoft or download them here

PLEASE VIRUS-SCAN ALL DOWNLOADS BEFORE USE

Current Version

Complete test-project documentation declares file and test program (ZIP)
V1.39 - 11th June 2011
1.71Mb ZIP
Requires VB5 runtimes only for the enclosed test-project

VBToolbox PDF Manual
V1.39 - 11th June 2011
(098kb /180+ pages PDF format)

* Previous versions should be discarded


Retired Versions

Complete test-project documentation declares file and test program (ZIP)
V1.38 - 23rd April 2011
1.47Mb ZIP
Requires VB5 runtimes only for the enclosed test-project

Complete test-project documentation

VBToolbox PDF Manual
V1.38 - 23rd April 2011
(807kb /164 pages PDF format)

Complete test-project documentation declares file and test program (ZIP)
V1.37 - 1st April 2011
1.47Mb ZIP
Requires VB5 runtimes only for the enclosed test-project

Complete test-project documentation declares file and test program (ZIP)
V1.36 - 26th March 2011
1.47Mb ZIP
Requires VB5 runtimes only for the enclosed test-project

VBToolbox PDF Manual
V1.36 - 26th March 2011
(781kb /158 pages PDF format)

Complete test-project, documentation, declares file and test program (ZIP)
V1.35 - 19th March 2011
1251kb ZIP
Requires VB5 runtimes only for the enclosed test-project

Complete test-project, documentation, declares file and test program (ZIP)
V1.34 - 12th March 2011
1251kb ZIP
Requires VB5 runtimes only for the enclosed test-project

Complete test-project documentation declares file and test program (ZIP)
V1.33 - 30th September 2010 - 1251kb ZIP
Requires VB5 runtimes only for the enclosed test-project

VBToolbox PDF Manual
V1.33 - 30th September 2010
(731kb /151 pages PDF format)

Download the complete test-project documentation declares file and test program(ZIP)
V1.32 - 10th September 2010 - 1158kb ZIP
Requires VB5 runtimes for the enclosed test-project only

VBToolbox PDF Manual
V1.32 - 10th September 2010
(700kb /140 pages PDF format)

Download the complete test-project documentation declares file and test program(ZIP)
V1.31 - 31st August 2010 - 1105kb ZIP
Requires VB5 runtimes for the enclosed test-project only

VBToolbox PDF Manual
V1.31 - 31st August 2010
(671kb /131 pages PDF format)

* Previous versions should be discarded

Download the complete test-project documentation declares file and test program(ZIP)
V1.30 - 30th July 2010 - 854kb
Requires VB5 runtimes for the enclosed test-project only

Download the complete test-project documentation declares file and test program(ZIP)
V1.27 - 3rd July 2010 - 807kb
Requires VB5 runtimes

Download DLL Only
V1.25 - 21st June 2010
(UPX compressed)

Download Test Program Only
V1.25 - 21st June 2010
(45kb compressed EXE)
Requires VB5 runtimes

Download the complete test-project documentation declares file and test program(ZIP)
V1.25 - 21st June 2010
Requires VB5 runtimes

Download DLL Only
V1.24 - 11th September 2009
(UPX compressed)

Download Test Program Only
V1.24 - 11th September 2009
(45kb compressed EXE)
Requires VB5 runtimes

Download the complete test-project documentation and test program(ZIP)
V1.24 - 11th September 2009
Requires VB5 runtimes

Webserver VB-CGI Demo
V1.21 - 1st September 2009
(17kb ZIP - with DLL)

AZDEMO VB-CGI Demo
V1.21 - 1st September 2009
(148kb ZIP - with DLL)

VBPi (PiStr() now removed)
VBPi pi Demo
V1.21 - 1st September 2009
(148kb ZIP - with DLL)


Suggestions and Updates

I have limited time to dedicate to this project but I am open to suggestions or source code for routines to add to the library. Ideally the library needs to be completely rewritten.

Virus Warning

You are responsible for scanning these downloads for viruses. They have been scanned by Avast! on upload but there is always the possibility they could get infected before you use them.

Requirements

You will also need to have msvcrt.dll installed in your \windows\system32\ folder. You can get this as a free runtime for MS visual C++. This provides access to C++ functions for Windows programs.

Compatibility

Visual BASIC 5/6 or higher. 32-bit 9x, NT, 2k XP, Vista, Windows 7
ReactOS/WINE

Warranty and Licence

This program is provided royalty-free and free of charge for educational and personal use only (freeware) with absolutely NO WARRANTY WHATSOEVER. It is released for personal and educational use only with strictly no permission whatsoever for commercial use.

By using the software you are deemed to have agreed to the licence conditions and agree use it at your own risk with no liability to the author for direct or consequential losses arising from it's use.

Copyright

The library, code and documentation is Copyright (c) to M Shaw 2003-2012. You may include and distribute this DLL royalty-free in non-commercial applications you write as long as you adhere to the licensing conditions. Due to potential legal liabilities, the DLL should not, under any circumstances, be used by or distributed with commercial applications without express written permission from the author.

Disclaimer

The program does not knowingly contain any malicious or dangerous functions but should, nevertheless, be thoroughly tested before use. Careless calls to DLL functions can inherently be dangerous to calling applications or your Windows system.


Useful Links

 

micro-apache-vice-shaded-blue.png (1573 bytes)
MicroApache
Portable Apache Webserver

Visual BASIC Developer's Forum

Visual BASIC at About.com

Visual Basic at Wikipedia

Visual BASIC Explorer

WebBASIC

Karl Peterson's Classic Visual BASIC

Boutell's GD Graphics Library


Open Office was used to product the project manual. Please consider using Open Office in preference to Microsoft Office

ooo_getlegal_120x60.png (13225 bytes)


Legacy BASIC

Rubbermallet.org - QuickBASIC Webserver and IRC for 808x PCs

 

About This Library

Update 2021. These legacy pages have been temporarily revived. The downloadable code may contain bugs which have not yet been resolved. The product must not be used in a production environment. If I can find time I will look at updating the code and providing a new release late 2021

VB5 and VB6 are still excellent languages to work with and there still remains an active and enthusiastic user-base (including myself!). There are also many Windows/Linux cross-platform BASIC equivalents or derivatives available, including projects such as FreeBASIC. However the VB5 is  lacking in certain areas - in particular, writing console-mode apps in VB5 is a pain. These deficiencies can be made up for by writing your own library functions in VB itself but this can be difficult to implement. Many VB programmers may also find difficult to replicate certain functionality in VB without knowing how to translate "C" source code. Interfacing with a DLL offers gains in all areas and can bring significant speed-improvements. This DLL project provides many routines written for tight execution in "C". They can sometimes execute hundreds of times faster than natively compiled VB code.

This is a tiny, pure "C" DLL as provided with commercial programs rather than a messy ActiveX DLL developed in VB. Function calls are easy, fast and transparent and the DLL requires NO ActiveX system registration using regsvr32.exe. Just copy to your system, add the BAS definition file and use it with your VB program.

Not Just VB Either!

VBToolbox isn't just limited to use only with Visual BASIC, it can add BASIC-like functionality to C/C++ programs and any language which can connect to external DLLs can use this library, benefiting from VB6-like functions such as Join, Filter, StrSplit, Tokenise, Qsort, etc to handle Variant arrays.. This would include more recent versions of VB DotNet, "C" or C++ compilers, C#, Delphi as well as scripting languages such as AutoIT.

The LIB linker file and declaration headers are available on request for "C"/C++ developers who wish to use the DLL (just ask). I have used the library with RTFCrypt which was written in VC++ v5.0.

The latest version of this library offers around 330 new functions and commands which are commonly implemented in VB code or called via the API but which can now be called directly from a DLL as if they were native VB commands. More are planned with an anticipated total of around 350 new features with a target size of about 90kb. Some of the bundled library functions have been used in a separate DLL for use with SendMail for Windows and have performed reliably over time. This project is intended for home users and hobbyists and should be subjected to thorough testing before being used outside that scope. It is not intended for commercial use.

I use the library for my own projects and am keen to ensure VBToolbox supports legacy versions of the Windows "NT" family, particularly NT 4.0 and Windows 2000, both of which now make an superb USB and VM-friendly O/S when run inside a secure host. You may wish to check out the freeware QEMU VM/PC emulator project

More information on calling VBToolbox from C/C++ and other languages is available here Calling VBToolbox from C/C++

A complete DLL-wrapper and VB5-compatible version of the latest SQLite is available More details here ...


Quick Install

If you want to just try-out and play with the supplied VB project there is no need to copy the DLL to your system folder. Simply unzip the supplied project to a convenient directory and run mslibtest.exe or load the VB project by clicking on project1.vbp. You need VB 5.0 or VB 6.0 in order to use the project.

If you want to use the DLL on a system-wide basis, simply copy the DLL (MSLIB145.DLL) to your \Windows\System32 directory. You may need to have the Microsoft Visual C++ Library DLL (msvcrt.dll) also in the same directory. The chances are that you have it already. If not it is freely available and there is a link to it on this page.

Using VBToolbox Within Visual BASIC

To make the VBToolbox functionality available from within your own VB projects simply drag and drop mslib145.bas into the project tree. You can then use the functions listed below. Alternatively, go to the project explorer tree, right-click on it then select, Add->Module, Existing Tab, and browse for mslib145.bas. There is no need to edit the included module, indeed, it is highly-recommended that the declarations for each specific version of mslib145.dll not be changed in any way.

IMPORTANT: Version Control

Because VBToolbox is under active development the interface may change over time. Version-control features are provided to help manage problems arising from this and to ensure that applications work with the correct version of the DLL. Ensure you have the correct DLL for any application you are using. You may need to put specific versions of the DLL in application folders instead of the system folder for older versions of test and demonstration code to work.


Documentation

The library is documented in this 180+ page PDF manual

Bug Reports and Feedback

Constructive feedback and bug reports (with useful information) are always appreciated
Click here to contact me or forward a bug-report (your email address will not be divulged)
Feedback is needed on testing in WINE/Linux, ReactOS, Win9x, NT, Windows XP and Windows 7

bug.gif (1567 bytes)

VBToolbox V1.40   Function List

View full export list

DLL Management  
IsDllInstalled VB wrapper function in mslib145.bas - Checks to see if the add-on DLL is installed and available
LibDate Returns the DLL's release date as String
LibTime Returns the DLL's release time as a String
LibUnicode Returns a Boolean indicating whether the DLL is the Unicode version or not
LibVersion Checks the installed DLL version (See above) - was originally declared as "_libversion"
CallDLL Calls an External DLL without needing a Declare or TLB file (returns a Long, DWORD or LPSTR)
CallDLLSingle Calls an External DLL without needing a Declare or TLB file (returns a Single floating point value)
CallDLLDouble Calls an External DLL without needing a Declare or TLB file (returns a Double floating point value)
CallDLLVariant Calls an External DLL without needing a Declare or TLB file (returns a VB Variant value)
CallDLLCDecl As CallDLL but uses the __cdecl calling convention for use with C/C++ or other languages than VB
CallDLLCDeclSingle As CallDLLSingle but uses the __cdecl calling convention for use with C/C++ or other languages than VB
CallDLLCDeclDouble As CallDLLDouble but uses the __cdecl calling convention for use with C/C++ or other languages than VB
DllVersion VB wrapper function in mslib145.bas
   
Windows API  
AddEventSource Adds this DLL as an event log message source (Warning: do NOT UPX-re-compress this DLL if you use this feature)
CanRedo Test if the Windows API can Re-Do an editing action
CanUndo Test if the Windows API can Undo an editing action
CommandLine Uses the API to retrieve the program's command-line (may be preferable to Command$ on occasion)
CreateGUID Create a globally-unique identifier (GUID) either in either formatted or plain hex
CreateShortcut Create a Windows shortcut (LNK) file
GetAppFileName Returns the equivalent of VB's App.Path value for those using other than Visual BASIC with VBToolbox
GetColourSelection Implements a Windows API colour selection window with static memory of custom colour selection
GetDLLFileName Returns the fully-qualified path and filename of the copy of VBToolbox DLL which you are linked to
GetNormalisedPath Correct and return a partial path value
GetOpenFile Get an "Open File" filename using a Windows API Open-File dialogue. Does not require the CommonDialog OCX
GetLocalDriveStrings Returns the current system drive letters in a String
GetProfileDir Returns common profile directory locations for folders such as "My Music" "My Documents". Supports all versions of Windows from NT (with IE5 installed) onwards. Requires Shell32.DLL or ShFolder.DLL installed.
GetSaveFile Get a "Save File" filename using a Windows API Save-File dialogue. Does not require the CommonDialog OCX
GetSystemDir Returns the current Windows system directory as say C:\Windows\System32
GetUserDir Returns the current top-level user directory as e.g. C:\Documents and Settings\Administrator (not Windows NT). Requires Shell32.DLL installed on the system.
GetVolumeFileSystem Returns the name of the installed file system on a given volume - e.g. "NTFS"
GetVolumeLabel Returns the volume name of a given volume
GetVolumeNameLength Returns the maximum filename for the filesystem on a specified volume
GetVolumeSerial Returns the volume serial number
GetWallpaper Get the current wallpaper BMP name and display style mode
SetWallpaper Set the workstation wallpaper and display style mode
GetWallpaperStyle Get the current display style (tiled, centred or stretched)
GetWindowCaption Returns a string containing the caption of a window
GetWindowsDir Returns the current Windows directory as say c:\windows\
GetWindowHandle Returns the handle of a window from it's instance handle or process ID (PID)
IsClipboardEmpty Tests if the Windows clipboard is empty or not
IsNetworked Tests if Windows has an active network session
IsMousePresent Tests if Windows has a mouse present
IsSafeMode Tests if Windows is running in "Safe" mode
IsSlowMachine Tests if the CPU is considered to be "slow" by Windows
IsUserAdmin Tests if the currently logged-in user is a member of the Administrators group
LogEvent Log an event into the system event log (Warning: do NOT UPX-re-compress this DLL if you use this feature)
MonitorCount Returns the count of VDUs connected to the system
PlayWAV Plays a Windows sound file (WAV)
PrintScreen Captures the current application window to the Windows clipboard
ReadDWORDFromRegistry Read a DWORD (Long) from the system registry
ReadStringFromRegistry Reads a string value from the registry
RemoveEventSource Removes this DLL as an event log message source (Warning: do NOT UPX-re-compress this DLL if you use this feature)
ShellRun Run a program, associated file or valid URl
ShowDesktop Show or hide the icons on the Windows desktop
ShowFileProperties Launch an Explorer "file-properties" pane for a given file
StopWAV Stops playing a WAV file previously started with PlayWAV
WinSleep Safely exposes the Windows API Sleep function
WindowsSubVersion Return the Windows sub-version number as a string - example for XP is "Service Pack 2"
WindowsVersion Return the Windows version number as a string - XP is "5.01"
WindowsVersionMajor Return the Windows major version number as a string - XP is "5"
WindowsVersionMinor Return the Windows major version number as a string - XP is "01"
WriteDWORDToRegistry Write a DWORD (Long) into the system registry
WriteStringToRegistry Write a string value to the registry
   
Process Functions  
GetPID Get Process ID (PID) of the current program
GetProcessMemoryUsed Find out how much memory a given process is using
   
String Functions  
AddString Use Windows API memory allocation rather than VB string space to concatenate 2 ASCII/ANSI strings
AddHugeBinaryString Concatenate two huge strings (300+ megabytes and over) transparently using memory or temporary files rather than VB string space
AddBinaryString Use Windows API memory allocation rather than VB string space to concatenate 2 binary/ANSI strings strings
ArgFound Check if an LValue is present of a given Variant string array
ArgVal Return the RValue for a given LValue of a given Variant string array
BracketStr Returns the contents of a section of a string which is enclosed by brackets
CharCount Returns a count of printable characters within a string (excludes newline and formatting chars)
Comma Convert a numeric value to comma-delimited form
CommaStr Convert a string-represented number to comma-delimited format
CString Manipulate strings with embedded "C"-style escape sequences
Filter Emulates the VB6 Filter() function - filters an array according to rules
GetArrayDimensions Get the number of dimensions of a Variant array
GetRTF Retrieve the RTF content of a VB Rich Edit control using EM_STREAMOUT callback process (experimental)
InChrRev Find the position of a character (passed as integer) from reverse end
InChr Find the position of a character (passed as integer)
InsertString Insert one string into another at any position to create a new string
InStrRev As InStr but searches from the end of a string in reverse order
InStrWildcard Version of InStr which supports the rudimentary use of wildcard matching using the "?" character (case-sensitive)
InStrIWildcard Version of InStr which supports the rudimentary use of wildcard matching using the "?" character (case-insensitive)
IsAllChar Is a string made up entirely of the specified character? (returns a BOOL)
FillString Fills a string with a given character quickly
FindClosingBrackets Find the location of a matching closing bracket for a given opening bracket position within a String
Join Emulates the VB6 Join() function for VB5 and compatible languages
MatchBrackets Check if bracket-pairs match within a string
ProperCase Convert the first letter of a string or the first letter of each word to Initial Caps
QSort. QSortStr Quicksort a VB string array
Replace Full string replacement within a string. For use with VB 4/5 only to emulate VB6 Replace
ReplaceChar Fast character replacement within a string.
ReverseWords Reverse individual words held within a string and delimited by white space
StripLStr Strips characters specified in mask on LH side of the string
StripRStr Strips characters specified in mask on RH side of the string
StripL Duplicates LTrim but can trim any character instead of just spaces
StripR Duplicates RTrim but can trim any character instead of just spaces
StrJoin Joins elements of a string array together into a single string. Similar to the VB6 Join() function
StrRev Reverse a string
SliceLeft Truncate a string by "N" characters without the need for VB to create temporary/intermediate strings and impacting on string space
StrCSpan Similar to the "C" strcspn() function. Returns the position of the first of any matching character from the given character mask string
StripTerminator VB wrapper function in mslib145.bas to remove C/C++ terminating NULL characters from returned DLL strings
StrSplit Splits a string similarly to the VB6 Split() function. For VB5 and other languages
SwapStr Rapid swapping (exchange) of strings by means of pointers
Tokenise Break a string into a string array (as Variant) - Similar to VB6 Split() function but tokenises on any character in a string mask
VariantToArray Convert a String Variant into an array
VBString VB wrapper function in mslib145.bas to remove C/C++ terminating NULL characters from returned DLL strings (required prior to V1.11)
WildcardMatch Match a string to a wildcard (not regex)
WordCount Returns a simple wordcount for a text String
WordList Returns a list of words in a Variant from a given string as would be processed by WordCount
WordWrap Wraps words at a given line boundary break value. Does not implement font-kerning etc.
   
Number Functions  
Bit-shifting ShlByte, ShrByte, ShlInt, ShrInt, ShlLong, ShrLong
Bit-rotating RotlByte, RotrByte, RotlInt, RotrInt, RotlLong, RotrLong
Ceil Rounds a floating point number up to the next highest integer
DecimalToRoman Convert a decimal value to a Roman number format String
Expr Evaluate a simple, non-bracketed mathematical expression held in a string
Expression Evaulate a complex, bracketed mathematical expression held in a string (used Expr recursively after "compiling" the expression)
Floor Rounds a floating point number down to the next lowest integer
FMod Exposes the "C" fmod() function which has a greater Double range than the VB Integer function
Fraction Returns the fractional part of a VB double variable (1234.56789 -> 0.56789)
Gcd Greater Common Denominator
Integral Returns the integer part of a VB double variable (1234.56789 -> 1234)
Max Maximum value
Min Minimum value
QSortVal Quicksort a numeric or date array (direct or as a Variant)
RomanCharDecimal Convert a Roman digit held in a String to a Decimal Long value
RomanToDecimal Convert a Roman number held in a String to a Decimal Long value
Round Returns a double, rounded by x places (For VB5)
  -
PiStr * Removed * to be migrated to PI.DLL - Return PI to up to 1000 decimal places
   
Date and Time Functions  
UKToISODate Convert a UK date as dd/mm/yyyy to an ISO date string as yyyymmdd (uses a static buffer)
ISOToUKDate Convert an ISO date as yyyymmdd to a UK date string dd/mm/yy (uses a static buffer)
UKShortToISODate Convert a short UK date as dd/mm/yy to an ISO date string yyyymmdd
IsLeapYear Returns a BOOL if the given year is a leap year
NumOrd Return the ordinal postfix for an integer value - e.g. 3 is "rd" (3rd)
PHPDate Emulates the PHP-style date formatting function taking a VB date-variable as input
PHPDateNow Emulates the PHP-style date formatting function using the current system time as input
VBDate Returns a formatted text-string containing a VB date represented as a C double variable
DSTAdjust Returns a VB date value as a double - adjusted by the current O/S Daylight Savings Time bias value (Usually +1 hr if in-force)
VBDateToCTime Returns a VB date variable converted to a "C" time_t value - returned as a VB long
CTimeToVBDate The inverse of VBDateToCTime
   
Data Conversion Functions  
ANSIStr Converts a VB String value to an ANSI string and returns a Long pointer - (creates a temporary ANSI string)
BaseConv Convert any decimal number to a string in any given base
Base$ Wrapper function for BaseConv
Bin8, Bin16 and Bin32 Numeric to binary-string conversion functions for Byte, Integer and Long data types
Bin$ VB wrapper function in mslib145.bas for Bin
BinToDec Convert a binary string to a decimal value as LONG
BitPack Pack (zip) a numeric string into binary format using a 4-bit packing system to reduce size by 50% (Useful for bitpacking PI)
BitUnPack Unpack (unzip) a binary string produced by BitPack
CharToOctal Convert a BYTE value to an octal string sequence
DecodeString64 The inverse of EncodeString64
DateToHex Create a useful and precise 16-character hex representation of the memory-image of a VB Date variable (or VB double)
DecToBin Intelligent wrapper for Bin8, Bin16 and Bin32 which calls the correct function depending on the size of the input
EncodeString64 Encode an ASCII string as Base64
CharToHex Convert a number 0.255 to a 2-character hex string value
FreeANSIStr Release a string which has been created by ANSIStr
HexToLong Returns a double (representing an unsigned long) value of an 8-bit maximum hexadecimal value (8 characters max)
HexToDouble Convert a string of up to 8 bytes (16 characters or 32 bits) into a double
HexToDate Convert a 16-character hex value created by DateToHex back into a VB Date or double
HexToStr The inverse to StrToHex
IntToHex Returns a 4-byte formatted hex string
LongCast Convert (cast) a VB String value to a Long for use with CallDLL*
LongToHex Returns an 8-byte formatted hex string representation of an unsigned long (takes a VB double)
Mki, Cvi Legacy BASIC. Make an integer byte-string (Mki) and Convert it back (Cvi)
Mkl, Cvl Legacy BASIC. Make a long byte-string (Mkl) and Convert it back (Cvl)
Mkf, Cvf Legacy BASIC. Make a float byte-string (Mkf) and Convert it back (Cvf)
Mkd, Cvd Legacy BASIC. Make a double byte-string (Mkd) and Convert it back (Cvd)
OctalToChar Convert an octal value to a BYTE number
Rot13 An implementation of the ROT13 encoding algorithm
RotateByte Rotate (mirror) the nibbles in a BYTE value - 2F -> F2
RotateInt Rotate (mirror) the bytes in a 2-byte integer value  2E34 -> 43E2
RotateLong Rotate (mirror) the bytes in a 4-byte long value  -  1A232E34 -> 43E232A1
StrCast Convert (cast) a Long returned by CallDLL* back to a VB String
StrToHex Convert an ASCII string to HEX equivalent string
   
Variant Handling Functions  
EmptyVariant Clears a Variant
   
Random Number Functions  
EncryptString Encrypt a string using weak symmetric encryption - decrypt with same function
Randomise Randomise or reset the C/DLL random-number generator
Random Return a random number between values x and y (inclusive)
RandomStr Return a formatted random string. 5 different formats available
MTRandomise Randomise or reset the Mersenne Twister random-number generator
MTRnd Return an long in the range low to high (inclusive)
MTRndDouble Return an double in the range low to high (inclusive)
MTRandomStr Return a formatted random string using the Mersenne Twister PRNG. 5 different formats available
   
Disk and File Functions  
AddTrailingSlash Add a slash intelligently to the end of a path string
CountFiles Count all of the (non-directory) files in a given folder according to a pathspec
DirExists Check if a file is a directory or not or if a directory exists DONE
DriveExists Check to see if a logical drive exists DONE
DiskFree Return the amount of free space on a disk in bytes
DiskFreeMeg Return the amount of free space on a disk in Megabytes
DiskFreeGig Return the amount of free space on a disk in Gigabytes
FileExists Test to see if a file exists
FilenameMatch Match a filename to a wildcard
FileCount Returns a count of matching files in a given folder
FileType Returns the filetype-extension for a given filename
GetDiskSize Get the physical size of a disk in bytes (returned as a Currency variable with optional bias adjustment)
GetDiskSizeMb Get the physical size of a disk in megabytes
GetDiskSizeGb Get the physical size of a disk in gigabytes (returned as a double)
GetDiskType Returns the type of disk
GetFileName Return the filename part of a path string as "filename.typ"
GetFileExt Return the filename-extension part of a path string as ".typ"
IsCDROMDisk Returns True if the specified disk drive is a CDROM, DVD or other optical drive
IsDriveReady Returns True if the specified disk is ready to be read and has media inserted
IsHardDisk Returns True if the specified disk drive is a fixed hard disk drive
IsRemovableDisk Returns True if the specified disk drive is a removable type drive such as USB or floppy disk drive
IsNetworkDisk Returns True if the specified disk drive is a mapped network disk drive
IsValidDisk Returns True if the specified disk drive is any type of valid and accessible disk drive
ListFiles List all of the (non-directory) files in a given folder matching the specified pathspec and return in a Variant as String() array
MKDirs Create several sub-directories in one operation
MkTempName Create a temporary filename with a guaranteed-unique random name with validation of drive-letter and source path
ReadFile Reads a file to a buffer
Unlink Deletes a file more controllably than using "Kill"
   
Internet/Network Functions  
GetCGIArgs Split a CGI argument string into values
IPToLong Converts a dotted-quad IP address string into an "unsigned long" (returns as a VB double)
LongToIP Converts an unsigned long value (sent as a VB double) into a dotted-quad IP address
IPMatch Match an IP address to an IP-address mask - wildcards are permitted
MapNetworkDrive Connect a network drive letter to a shared network folder
MapNextFreeNetworkDrive Connect the next unused drive letter a network drive letter to a shared network folder
MatchCIDR Match an IP address to a standard CIDR mask string
UnmapNetworkDrive Disconnect a previously-mapped network drive
URLEncode, URLDecode Encode or decode a URL string
   
Console Functions (This cannot otherwise be done in VB5 without lots of messy Windows API code - Supports Win32 server CGI)
Beep Enhanced system beep
ClearConsoleAttributes Resets the colour attributes back to standard colours
CloseConsole Close a previously opened console window
Cls Clear the console window
ConsoleOpen Returns TRUE if a console was successfully opened and the handle to stdout assigned
ConsoleTitle Set the console title
ExitProgram Exits a console program with errorcode passed via a Long integer
FlushConsole Flush buffered console output
GetArgs ArgV and ArgC - C-like handling of Command$
GetConsoleHandle Retrieve the Window handle of an open console session for use with other API functions
GotoXY Locate (position) the cursor in an open console window
InKey As per legacy BASIC Inkey$ - monitor for a keystroke return
InNativeConsole Returns True (-1) if running as a converted/native Win32 console application
This is a means of detecting conversion using LINK.EXE (see console app conversion)
OpenConsole Open a CMD console window
Pause Pause for a keypress
PrintR Debug print variables to the console in human-readable format (debugging tool)
PrintStringArray Debug print a String() array to the console (similar to PrintR)
ReadLn Read a line of text from a console window (using stdin)
SetConsoleAttibutes Sets the colour attributes for an open console window
SetConsoleHTML Sets extended "HTML" CRLF formatting for the WriteLn command (this appends a <br> at the end of each line)
WriteLn Write a line of text to a console window terminated by a CRLF (using stdout)
Writes Write a line of text to a console window with no CRLF (using stdout)
WhereX and WhereY Return the console cursor locations (X and Y)
   
Graphics Functions  
BGRSplit Split a VB OLE_COLOR or other "Long" colour value into Red, Green and Blue components
RGBToBGR Rapidly switch between a Visual BASIC BGR (Blue,Green,Red) format to true RGB (Red, Green, Blue)
BGRToRGB Rapidly switch between a Visual BASIC BGR (Blue,Green,Red) format to true RGB (Red, Green, Blue)
RGBSplit Split a standard 24-bit "Long" RGB value #RRGGBB into Red, Green and Blue components
BMPToString Convert a BMP data-block created with StringToBMP back into the original data
BMPDataSize Returns the size of a data block stored within a BMP image by StringToBMP
BMPInfo Retrieve basic bitmap information
IsBMP Determines if a VB string holds a Windows BMP binary image
JPEGCheck Check a JPEG file for basic structural faults
JPEGHeader Check a JPEG file for basic structural integrity and return the pixel width, pixel height and file length in bytes if OK
StringToBMP Convert any string of data into a valid 2-colour Windows bitmap - useful as an encryption container
 
Email Functions MAPI Email Functions
MAPISend Email a message or a file as a MAPI attachment (experimental for V1.21)
   
Compression Functions  
RLECompress Compress a binary or text string using Run-Length compression
RLECompressible Returns whether a given block of data can be compressed using RLE compression or not
RLEUncompress Uncompress a string compressed with RLECompress
RLECompressByteCount Calculate the compressed size of a binary or text string
RLEUncompressByteCount Calculate the uncompressed size of a string compressed using RLECompress
 
Debug Functions
PrintDebug Outputs a string to the registered debugger via the Windows API
   
In The Next Release Features planned for future implementation in the next release
v1.40 VBNow , CallDLLCDecl, CallDLLCDeclSingle, CallDLLCDeclDouble, CStrToVBStr, VBStrToCStr, CStrFree
v1.39 - released CString (Use "C"/C++ style escape sequences in VB strings). CharToOctal, OctalToChar, Beep, Bugfix MK*, CV*, CallDLL*  - Uses assembler code to all external DLLs on-the-fly without TLB or Declares, ANSIStr, FreeANSIStr, LongCast, StrCast, EmptyVariant. Revised PrintR with the ability to handle recursive arrays. PrintStringArray debug routine.
   
Planned Stuff Features planned for future or long-term implementation in some future release ...
Other stuff I am looking at: I'm working on a "C" or "C"-like script-interpreter which will probably use VBToolbox code either dynamically or statically-linked. I have added CallDLL features which will allow an interpreted script language to call just about any DLL function in real time.
New expression evaluator to replace Expression() Write a new expression evaluator based on RPN and which can handle operator precedence, variables, multi-line expressions with comments etc. and a wider range of math functions. This may include a "C"-like macro language although this may end up as a separate project and a new DLL. Intrinsic in this project would be the ability to call external DLLs to increase functionality.
mini-regex functions Currently in prototype using interpreted Ch. A regex-array filter function and "Like()" function is planned
CGI Helper Code Some more Web-CGI helper functions (CGIArgValue etc.)
Simple AES encryption If I can convert/migrate some of the PD code which is available into "C". I am wary at using any GPL encryption code since I don't want the rights to use my own source code for commercial purposes to be diluted and to lose the right to my own code. The encryption I have is good-enough for now so this is not a high-priority.

Page top


Updates and News

Pending June 2012 1.40 - Bugfixes and Additions.
Bugfix in date functions which may cause time to advance by +1 hr after calling with a Unix "U" format code .
Bugfixes in GetCGIArgs, GetArgs, Join ProperCase didn't apply to all-CAPS Revise ProperCase for sentence use and personal pronoun
Added: NumberType, JoinRelativePaths, ConvBase, DetectNumberBase, VBNow (equivalent to VB's Now() function)
Added
__cdecl CallDLLCdecl* routines for use with C/C++ and other languages which may wish to call external DLLs which have been written to use the _cdecl interface
Added CStrToVBStr, VBStrToCStr, CStrFree - "C" string memory-allocation/deallocation/conversion routines for use when calling __cdecl external "C" DLLs|
Working on C# interface protocols for CallDLL and other routines (now working)
11th June 2011

Large rewrite, centred around the implementation of CallDLL routines.

1.39 - A fair amount of code has been rewritten to enable interfacing with the new CallDLL* functions
Added CallDLL(), CallDLLFloat, CallDLLDouble, CallDLLVariant to call *any* external DLL without need for a TLB file or declare.
Bugfixes in Mkf, Cvf, Mkl, Cvl. Added CString, OctalToChar, CharToOctal, Beep
Added RANDOM_STYLE_PRINTABLE, RANDOM_STYLE_OCTAL, RANDOM_STYLE_HEXALL to RandomStr,

CallDLL*  - Call external DLLS on-the-fly without TLB or Declares,
ANSIStr, FreeANSIStr, LongCast, StrCast
Revised PrintR with the ability to handle recursive arrays
GetArgs and GetCGIArgs now has an array base parameter with the default set at 1
Minor bugfixes after an audit with CPPCheck
Bugfix in QSortVal resolved. Some functions rewritten to take a String() rather than Variant() array|
Added PrintStringArray to complement PrintR
Bounds iteration errors on some Variant array handling functions fixed
VariantToArray is now a built-in function rather than VB code
Declares changed for: WordList, Join, Filter, CSVSplit, ListFiles, Tokenise, StrSplit, ArgVal, ArgFound, GetArgs, GetCGIArgs
Documentation updated to over 180 pages with more example code
Several Variant/Array based functions rewritten to properly handle an array base of arbitrary size rather than 0 or 1
Please donate Bitcoin - 1EAio6MjzH8NaTzxwfStAH5joh8K6gz6GN (or donate via PayPal link above)
23rd May 2011 1.38 - CreateShortcut, CharCount, ProperCase, ShowDesktop, PlayWAV, StopWAV, GetWindowCaption, GetWindowHandle, Rot13 . Documentation updated for this release.
1st April 2011 1.37 - IsUserAdmin (NT/2k/W7-compatible). IsBMP. GetRTF (Experimental retrieval of VB RTF control RTF). Minor bugfixes to BMPInfo and BMPFileInfo
26th March 2011 1.36 - Rewrote AddHugeBinaryString to handle strings of over 300mb with automatic switchover to using temporary files on the hard drive where there is insufficient memory to join the inputs. Resolved a bug in CreateGUID. Documentation updated.
19th March 2011 1.35 - Interim release to fix regression-bugs detected in the RLE compression library. Added GetColourSelection, AddHugeBinaryString which concatenates huge strings up to 2-300 Mb transparently using temporary files. Implemented to support RTFCrypt
12th March 2011 1.34 - AddString, AddBinaryString,  SliceLeft, error codes added to ReadFileToString, MidCharStr, MidStrStr. These updates either add enhancements over standard VB function such as Mid$() or reduce the impact on VB string space when handling extremely large strings of up to several hundred megabytes by removing the need for VB to create temporary strings or using duplicates (SliceLeft)
23rd February 2011 Donate Bitcoin - 1EAio6MjzH8NaTzxwfStAH5joh8K6gz6GN (or donate via PayPal link above)
1st October 2010 v1.33 - ExitProgram, GetError, IsClipboardEmpty, MKDirs, PrintDebug, ShowFileProperties, SwapStr, PrintScreen, DecimalToRoman, RomanToDecimal, DecimalToRomanChar, WordWrap, MatchBrackets, PrintScreen, WindowsVersionMajor, WindowsVersionMinor, ReverseWords, StrCSpan, CanRedo, CanUndo, FMod, GetFileName, GetFileExt, Expr, Expression, InStrWildcard, InStrIWildcard, SetConsoleHTML, CommandLine, DecToBin, InsertString

Mathematical expression/calculation functions added which can take a complex string-expression, evaluate it and return the result as a Double

Several more bugfixes which were highlighted during the development of Expr() and Expression()

A small web-based example online expression-evaluator written in VB5 with VBToolbox (CGIExpr) is available for testing on this page

10th September 2010 v1.32 - Minor bugfixes. CSVSplit, IsReady, GetVolumeFileSystem, GetVolumeLabel, GetVolumeNameLength, GetVolumeSerial, IsMousePresent, IsNetworked, IsSafeMode, IsSlowMachine, WordCount, WordList. Added Data-type Single to QSortVal and PrintR
31st August 2010

Huge rewrite: TLB/Unicode version included

v1.31 - Stub test executable with CGI-test ability and exported DLL interface which is compatible with RUNDLL32.EXE for test purposes
VB6 Join and Filter emulated for VB5 and clones. StrSplit and VariantToArray documented. Manual updated
Changed InstrI to find "" at location 1 in non-empty string the same as VB
Improved: FileCount. Rewrote ListFiles for precise file count handling in all cases. Many other functions being rewritten
Very rapid pointer-driven "C" quicksort added which can handle numeric, Variant and String arrays
PrintR debugging aid added. Test feedback appreciated, particularly due to the scale of the rewrite and brand-new Type-Library (TLB).

Type Library and Unicode support

During August 2010 I investigated producing a Type-Library but unfortunately they have annoying restrictions when used with VB5 which result in an automation error in some cases with the error message:  "Function or interface marked as restricted or the function uses an automation type not supported in visual basic" This then completely disables the declared function from use but lists it in the object-browser OK. There are a number of triggers for this including functions returning BSTRs via LPSTR function returns. VB6 also is reported not to support TLB long and __int64 (Currency) data types via the MIDL automation interface. The documentation for MIDL/ODL is also absymal and confusing so creating one and learning the syntax has involved some detective work.

After investigating the issues I decided to develop two versions of the DLL, one ANSI which supports Declare statements and the other a Unicode version with Type Library (TLB). This is because the use of TLB forces VB to pass and accept returns all strings as Unicode rather than ANSI BSTRs (Unicode being the VB internal default). This has involved completely rewriting huge sections of the library but this has also given the excuse to rewrite a lot of functions to include long-standing bugfixes. I don't like the idea of two versions of the DLL but offering TLB support requires it. TLBs are less-flexible and the only advantages are quicker execution due to "early-binding", not requiring messy Declares and the ability to browse objects. It won't offer 100% full international Unicode support but it's a big step in the right direction of providing it. Many of the functions are not Unicode dependent in any case.

Since this was a large rewrite I anticipate there will be a few bugs and tweaks which will necessitate a follow-up update in a week or two (1.32)

New Functions:
Join - As per VB6
Filter - As per VB6
GCDDouble - Find the GCD of two Double values
GetArrayCount - Find the # of elements in an array
PrintR - Variable debug utility similar to PHP's print_r()
FlushConsole - Flush buffered console output
QSort and QSortStr - Quicksort VB string arrays
QSortVal - Quicksort VB numeric and Date arrays
LibUnicode, LibDate and LibTime version control functions

30th July 2010 v1.30 - Low-level bitshift and rotation functions for encryption and graphics. ShlByte, ShlInt, ShlLong, ShrByte, ShrInt, ShrLong, RotlByte, RotrByte, RotlInt, Rotrint, RotlLong, RotrLong, Unlink, MKTempName. Type Library Support framework in place.
23rd July 2010 v1.29 - GetUserDir, GetProfileDir, WipeFile, GetAppFileName, GetConsoleHandle. Programmer's manual updated.
Domain name and URL for this page changed from http://vbtoolbox.amadis.sytes.net to http://vbtoolbox.kerys.co.uk
Formal release of v1.28 was skipped due to the domain name change but was supplied with EditPad and not fully documented/released here
3rd July 2010 v1.27 - New functions BGRSplit, BGRtoRGB, BMPDataSize. Dependencies on static variables removed from most functions to enable them to be more "thread-safe".
21st June 2010 v1.25 - After a layoff of several months the project has been picked back up. Development had stalled whilst working on EditPad's Bitmap encryption and wrestling with embedding BMP files, unaltered, into the RTF container object. Changed RLE function prototypes. Added RLECompressible. Fixed re-entrancy problems with date-related functions (PHPDate etc.). BMPInfo, StringToBMP and BMPToString released. See MSLIB145.BAS in the full ZIP project for updated declares.
11th September 2009 v1.24 - Added RLECompress, RLEUncompress, RLECompressByteCount and RLEUncompressByteCount. Added new RandomStr() parameters RandomStringHex, RandomStringBinary, RandomStringBinaryStringBias0, RandomStringBinaryStringBias1. Fixed bit shift error bugs in Bin8, Bin16 and Bin32
3rd September 2009 v1.22 - Added message body to MAPISend() and made all arguments optional. Added GetProcessMemoryUsed. Loop timers added to test rig. Windows 7 tests are significantly (about 10x) slower than Windows XP. I have no idea where the bottleneck is other than the fact that the version used for testing is a pre-release Windows 7 build (7100). Figures from below show results on two 100% identical Acer Aspire One machines with a Compaq Presario added for comparison. Function PiStr() has been removed pending migration to a separate DLL (PI.DLL)

Machine Model Total Time (100 loops) Average Time/Loop
Acer Aspire One - Windows XP (hyperthreaded dual core/1Gb) 73.906 seconds 0.74s
Acer Aspire One - Windows 7/Build 7100 (hyperthreaded dual core/1Gb) 246.467 seconds 2.46s
Compaq Presario V6314EA (dual core/1Gb) 34.125 seconds 0.34s
1st September 2009 v1.21 - Extensive rewriting of code to eliminate memory-leaks which had come to light. Leak tests show zero memory leaks. Test program rewritten to include up to 1000 loops of the basic test schedule. Added MAPISend(), StringToHex(). Used for optional encryption with EditPad RTF editor. f
20th July 2009 v1.20 - Tested with Windows 7 candidate release build 7100. Compared across two identical spec machines with Windows XP Pro I found that Windows 7 was at best 300% (3x) slower and, at worst 1000% (10x) slower running the test code. Adding extra timers showed this slowness to apply entirely across the range of test functions. Fingers crossed this will not be the case in the final release version
Released example CGI AZDemo.exe
6th December 2008 v1.20 - Bugfixes for GetArgs() and GetNormalisedPath() in order to handle quoted command-line filenames with embedded-spaces
21st July 2008 VBSQLite DLL wrapper for SQLIte 3.5.9 released - see the SQLite page
19th July 2008 v1.19 - ArgFound, ArgVal, DllPath, GetDiskSize/Mb/Gb, WriteDWORDToRegistry, ReadDWORDFromRegistry, WriteStringToRegistry,
          HDTEST (PIO/UDMA diagnostic utility made using VBToolbox)
10th July 2008 v1.17 - Rotate<TYPE> JPEGCheck, JPEGHeader, GetPID, HexToLong, HexToDouble, ListFiles, FilesMatch, WildcardMatch, GetFileOpen, GetFileSave
6th July 2008 v1.15 - Many new functions including GetArgs, Tokenise and several new console and API functions
30th June 2008 v1.14 - Full string Replace implemented for VB5, console defs updated
28th June 2008 v1.13 - StripX's rewritten to allocate new strings on return, InstrI added, Replace renamed as ReplaceChar pending a VB6-style Replace
27th June 2008 v1.12 - The need for VBString to strip terminating nulls from functions which return strings has been removed
Basic console functionality added and demo Webserver-CGI program added to the site
22nd June 2008 v1.10 - New functionality. DST bugfixes - PHPDate("W") implemented.
22nd June 2008 v1.09 - Many major updates including the addition of many date/time functions such as an emulation of the PHP date function
1st June 2008 v1.07 - Minor revisions to the documentation and erratum. Test programs and skeleton code corrected and updated. I am busy going through old code trying to piece back together code which was lost and release more coherent versions of the DLL and test-rig code.
2nd June 2008 v1.05 - Several new functions added to the library. Test rig rewritten
1st June 2008 v1.04 - Development restarted

DLL Test Rig

A "test rig" called mslibtest.exe is available (included with the full ZIP distro). Each "rig" release will be version-specific to the release of the DLL since calling parameters may change.Using code with the wrong calling-parameters referencing a DLL will almost certainly mean the test-app will crash. The declarations are made in mslib145.bas

VBToolbox test program

Click for a larger image of the test-rig running on a Compaq Presario V6000 series - (September 2009)

Page top


Function Differences Between VB5 and VB6

Visual BASIC 6 adds the following functions. Additionally VB6 is capable of the following

  • Functions can return arrays whilst VB5 cannot although VBToolbox returns arrays via Variant containers
  • Improvements to StrConv locale support
  • You can access properties using a name string
  • Better UDT support

I also stumbled across the excellent VBSpeed site - August 2010. After hacking this stuff for several years I find that others are or were doing the same thing!

VB6 Function Comments VBToolbox Test Timings

Filter

Replicated by VBToolbox - different syntax, use a wrapper Replacement  

FormatCurrency

- -  

FormatDateTime

- -  

FormatNumber

- -  

FormatPercent

- -  

InstrRev

Replicated by VBToolbox Direct replacement  

Join

Replicated by VBToolbox Direct replacement Tests:46ms, 64ms, 0.31ms, 35.9ms See VBSpeed

MonthName

Use VBToolbox's PHPDate with date formats -  

Replace

Replicated by VBToolbox -  

Round

Replicated by VBToolbox Direct replacement  

Split

Replicated by VBToolbox more flexibly using StrSplit and Tokenise -  

StrReverse

Replicated by VBToolbox -  

WeekdayName

- -  

Brief Usage Notes

  • The use of VBString to strip terminating null characters is no longer required from v1.11 onwards unless a function returns binary data (such as BitPack)
  • Unicode: The library does not directly support Unicode other than via Visual BASIC's internal translation to and from ANSI

Page top


Using Visual BASIC 5 or 6 and VBToolbox to Create True Win32 Console Programs

From v1.12+ basic console functionality has been added to enable you to create console-based applications with a few simple commands. Visual BASIC creates Windowed rather than console applications, this means that any VB program has to open it's own console Window. You can do this using the new OpenConsole function although this may not always be desirable. Once a console window has been opened you can read and write to it using ReadLn and WriteLn. When you have finished writing console text remember to call CloseConsole to properly release the console window's resources. See the manual for more information. This behaviour may be undesirable for a number of reasons - e.g. command-line programs which need to interact with the console or CGI applications where the overhead of opening a console window is undesirable.

Full 100% Console-Mode App Conversion

There is a simple modification you can optionally make to your compiled VB executable (EXE) file which will turn it into a full and normal Win32 console application which does not open a new console window and which will interact normally with a standard command prompt and, for example, redirect or pipe it's output into a file. Handles for stdout, stdin and stderr are captured. The conversion is quick and easy to do and relies on a free utility.

The console functions of VBToolbox work just fine with such converted programs and need no special programming or changes. Just compile and do the following to your exe file. If run from Windows Explorer your program will open it's own console window otherwise it will reuse the existing one automatically.

Download v5.12.8078 of Microsoft's linker program, LINK.EXE and associated EDITBIN.EXE v5.12.8078. The best place I have found is to download it with MASM32 a freeware Macro-Assembler. Note and accept the licence conditions and install MASM32 to a folder on your hard drive. (Note that you may need to temporarily disable DEP (Data Execution Prevention) on XP for the install to complete successfully). You probably need Microsoft LINK and EDITBIN version 5.12. The version of LINK/EDITBIN bundled with VB5 (v4.20) won't work and oddly, nor will some higher versions such as v7.10 (MSVC++ 2008 Express edition).If you know another legal source for a compatible version of LINK and EDITBIN please drop me a note. I've scoured the Microsoft site and can't find it available separately. With all versions the /EDIT command seems to be undocumented and does not appear in the help screen. On incompatible versions the command gives warning LNK4044: unrecognized option "EDIT"; ignored;

This method of conversion has been tested with VBToolbox console code on Windows XP, Windows 2000 and Windows NT 4.0 (SP6a)

  • Once MASM32 is installed into, say c:\masm32\ ...
  • Compile your VB program which links to VBToolbox's console features.
    Ensure you have "Compile to native code" enabled in your Project options under Project->Properties->Compile Tab->"Compile to Native Code" (this should be the default)
  • Open a CMD prompt and change directory to the one which holds LINK and EDITBIN v5.12.8078
    (should be in C:\MASM32\BIN)
  • Run the following command to convert your compiled EXE
    LINK.EXE /EDIT /SUBSYSTEM:CONSOLE <filename>
  • For example: for the vbcgi project, compile then run
    LINK.EXE /EDIT /SUBSYSTEM:CONSOLE vbcgi.exe
  • Alternatively, you can call EDITBIN.EXE directly using
    EDITBIN.EXE /SUBSYSTEM:CONSOLE <filename>
  • You will see the following displayed on successful conversion (no detailed confirmation message)

    Microsoft (R) COFF Binary File Editor Version 5.12.8078
    Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
  • That's it - you can now test your application

Full Console App Demos

This is a tiny 10k demo program to print out PI to 1,000 places. It is available as a Windowed console app version, or as a Converted (Native) console app version. You can also download the complete (project files - 92kb ZIP format). Note that this example requires an older version of the VBToolbox DLL and the PiStr() function is no longer included.

The console functionality has been tested successfully with VB 5 on Windows NT 4.0 (SP6a), Windows 2000 (SP4) and Windows XP (SP2)

VBToolbox console app demo

Page top


SetWall - Wallpaper Changer - A Full Demonstration VBToolbox Console Application

I wrote SetWall in a few hours to demonstrate some of the console functionality within VBToolbox. The complete project including source-code for SetWall is available for download as freeware.

This application will either set your wallpaper to a given filename or can cycle through a subdirectory of many files changing your wallpaper every few minutes or seconds. Both bitmap (BMP) and JPEG (JPG) files are supported. The latter are converted by SetWall into BMP files and saved, if possible into your user-profile directory as "Setwall-temp.bmp".  SetWall uses very little CPU time but obviously will keep your hard drive busy if you choose to change your wallpaper every 10 seconds using JPEG files.

SetWall can be driven from a batch file or Windows shortcut (or both). Using a shortcut you can minimise the app to your toolbar. The program is not CPU intensive particularly if you change your background less frequently than every minute. Use SETWALL /? to get the help screen.

Note: Corrupted or "broken" JPEG files can cause Visual BASIC apps which use an Image-control to hang when the image is loaded into a .Picture object. This can happen even if other applications can handle and workaround corrupted file problems. You should verify any JPEG image collections for errors if you find SetWall halts or hangs at a given JPEG image. Be aware that there are faulty JPEG images which have been crafted to exploit buffer-overruns and inject working code into your system. This is a problem with the VB control which hangs without reporting an error to the error-handler if it encounters a corrupted JPEG image (i.e. premature end of file due to bad-download). Download "Bad Peggy" JPEG Validator from www.hotpixel.net (Free) and scan your JPEG files for errors.

VBToolbox wallpaper changer

SetWall 1.02 on Windows NT 4.0/SP6a
(Click for larger image)

Command Description
SETWALL /? Show the help and command hint screen
SETWALL filename.bmp Set the wallpaper once to filename.bmp
SETWALL filename*.bmp Set the wallpaper to the first file matching filename*.bmp
SETWALL filename.jpg Set the wallpaper to JPEG image filename.jpg. This creates a temporary file in your Desktop profile or in your TEMP folder
SETWALL filename*.jpg Set the wallpaper to the first file matching JPEG file
SETWALL x:\path Set the first BMP or JPEG image found in x:\path
SETWALL x:\path\*.* Set the first BMP or JPEG image found in x:\path
SETWALL x:\path\*.jpg Set the first JPEG image found in x:\path
SETWALL x:\path /cycle Set, and cycle-through all JPEG and BMP files in x:\path until a key is pressed
SETWALL x:\path /cycle /time:30 As above  but change the wallpaper every 30 seconds
SETWALL x:\path /cycle /time:30 /Q As above  but don't display any text output
SETWALL x:\path /cycle /stretch Set and cycle wallpapers from x:\path and ask Windows to stretch them to fit (does not maintain aspect ratio)
SETWALL x:\path /cycle /tile Set and cycle wallpapers from x:\path and ask Windows to tile each one
  • Download the SETWALL program only. - Native console application - (Requires VBToolbox DLL (MSLIB145.DLL) V1.15+) - 72Kb UPX compressed ZIP
  • Download complete SetWall Visual BASIC 5 project and source code as a ZIP file (215Kb ZIP file - includes EXE and DLL)
  • If you are running on a very old copy of Windows and don't have VB installed you may not have the Visual BASIC runtimes. This program should not require a setup disk but if you have problems try downloading the runtime files from Microsoft. The required VB runtimes are present on newer versions of Windows.
  • View the Sample source-code for SetWall (may not be the latest version)
  • Note that the SetWall release may sometimes use a different DLL version to the main release

Page top


Using Visual BASIC and VBToolbox for Web Server CGI Processing

VBToolbox now provides functionality for text-mode console output and thus server-CGI back end processing. This means you can take-advantage of the full VB/ODBC database connectivity using legacy VB code and software to develop apps for your personal/home webserver. It also helps extend the life of Windows 2000/XP.

If you fail to install MSLIB145.DLL to your webserver there will be NO output unless you choose to provide and/or trap it. Most of the examples will log an error to the system error log in such cases.

You can download the small 7kb test executable, written and compiled in Visual BASIC 5 - and HTML test form as a ZIP file from here (requires V1.12 or higher for console functions).

You can also download a "no-install" or "portable"/USB-friendly copy of MicroApache webserver to test this from http://microapache.kerys.co.uk If running on an older version of Windows you may need the Visual BASIC 5 runtimes available from Microsoft or in a cut down distro from here. http://software.kerys.co.uk/dummy/

A Visual BASIC version of the common assembler CGI "asmdemo" which simply displays ASCII characters from A to Z, (although this one shows in random colours), is available here along with the project files. The actual CGI EXE is a mere 15kb.

The CGI demo and console functionality has been tested successfully on Windows XP (SP2), Windows 2000 (SP4) and Windows NT 4.0 (SP6a) and Windows 7 build 7100 with Apache 2.0.61/Win32

Applications which have been converted to full console EXE using LINK (see above) work OK with CGI.

The result from posting to TEST.HTM, a simple CGI form demo (opposite)

VBToolbox CGI Demo
VBToolbox VBCGI.EXE Demo running on MicroApache/Windows XP Professional(SP2)

The simplest VBToolbox/VB5 CGI program...

Sub Main
  OpenConsole
  Writes "Content-Type: text/html" & Chr$(10) & Chr$(10)
  WriteLn "<h1>Hello World!</h1>"
  CloseConsole
  END
End Sub

Console CGI Demo

Below is the amended VBToolbox CGI demo program, which demonstrates basic console I/O, running natively in a command-prompt window (console) on XP

 

 

 

VBToolbox console CGI demo

Live Console CGI Web-Demo - Expression Evaluator

This is a small Win32 dual console and CGI application of about 18kb (compressed) written in Visual BASIC which creates it's own input form and allows a user to input a complex mathematical expression and have it evaluated. Input is either via the built-in form or via a url-encoded URL string.

Standard mathematical operators are available with the Expression function offered via VBToolbox as well as a few more advanced ones such as bit shifting and Boolean comparison and evaluation of Roman, Binary and Hex values. If you wondered what "&rxxii/&rvii" is, or perhaps 2+2 now you can find out.

The application may also be run as a Win32 console app, returning it's result via the ERRORLEVEL environment variable as a Long integer (if it will fit).

Download Demo (v1.02 + VBToolbox v1.39)

Page top

screenshot-expression-crop-251.jpg (22271 bytes)
Live Console CGI Web-Demo - Text Base Converter - Convert Text to Binary etc.

This is a small Win32 dual console and CGI application of about 21kb (compressed) written in Visual BASIC which creates it's own input form and allows a user to convert text-input into formatted text in any base from base 2 to base 16

This application used VBToolbox v1.40 (not yet released - Oct 2011) and the BaseConv/ConvBase functions to convert the data. The data is bundled into blocks for human convenience and blocks are separated by space characters and are set to the data-width required to represent 255 at the given number base, padded on the left with zeroes. On decoding, if the user selects a base value which is too low then DetectNumberBase will try to detect and correct the base value. Excess CRLFs in the ciphertext are stripped out using StrSplit and Join

Now is the Winter of our Discontent in Base 3...

002220 011010 011102 001012 010220 011021 001012 011022 010212 010202 001012 011102 010220 011002 011022 010202 011020 001012 011010 010210 001012 011010 011100 011020 001012 010201 010220 011021 010200 011010 011002 011022 010202 011002 011022 001012 002212 010121 010201 010202 001012 010211 011000 011010 011020 010220 011010 011100 011021 001012 011021 011100 011001 011001 010202 011020 001012 010122 011111 001012 011022 010212 010220 011021 001012 011021 011010 011002 001012 011010 010210 001012 010022 011010 011020 010222 002012 001012 002102 011002 010201 001012 010121 011000 011000 001012 011022 010212 010202 001012 010200 011000 011010 011100 010201 011021 001012 011022 010212 010121 011022 001012 011000 011010 011102 001110 011020 001110 010201 001012 011100 011011 011010 011002 001012 011010 011100 011020 001012 010212 011010 011100 011021 010202 001012 002201 011002 001012 011022 010212 010202 001012 010201 010202 010202 011011 001012 010122 011010 011021 011010 011001 001012 011010 010210 001012 011022 010212 010202 001012 011010 010200 010202 010121 011002 001012 010122 011100 011020 010220 010202 010201 001201

Page top

screenshot-baseconvx400-crop.jpg (30168 bytes)

Click the image to try the application out

Demo MakeGUID Program - Create Yourself a Unique GUID String

This is a tiny 7kb server CGI program written to use VBToolbox console I/O, which does nothing more than create a 128-bit (16-byte) globally-unique identifier key using the v1.19 CreateGUID() function. Click here to try it out or get yourself a unique GUID string for your own program. Click here to download the complete project and EXE file (128Kb ZIP)

Page top


Getting SQLite 3 to work with Visual BASIC 5

Yes, it can be done!. This was a major head-scratcher but after a day puzzling out the existing code I ended up rewriting the lot and now have it working very nicely in VB5 using a couple of "C" functions from borrowed the VBToolkit. This warrants a separate page - check it out here...

Page top


HDTest - A Free IDE ATA/ATAPI + PIO/UDMA Diagnostic Tool Using VBToolbox

There is a persistent bug in XP and possibly in Windows 2000 whereby a given number of disk-read (CRC) errors will cause Windows to automatically "downgrade" to a slower and less-efficient method of disk access. The worst-possible outcome is that disk access is downgraded to PIO mode which has a top throughput of between 3Mb/Sec and 11Mb/Sec. Compare this with UDMA 5 throughput of around 100Mb/Sec and you may notice a few problems if your disks are running at 1/10th of their normal speed. The fault most commonly affects CD/DVD drives but may also affect IDE drives if a bad-sector is encountered. With catastrophic results for PC performance.

Such problems may include disappearing icons, applications freezing/locking up. EXTREMELY slow startup (possibly 5 to 10 minutes for Windows XP even on a 2Ghz processor). Applications may cease to respond for many minutes. The event log may also show spurious errors caused due to  driver or application timeouts.

VBToolbox IDE UDMA test demo

Microsoft have documented a patch and a workaround for this issue. One of the fixes included deleting the IDE driver from within Device Manager then rebooting. Not for the feint-hearted. This is a small utility which can diagnose whether UDMA mode is operational and, hopefully, fix the issue by applying the Microsoft-recommended registry tweak.

You may find it interesting to run this program after you have tried reading extremely scratched music CDs. It may save you literally hours of fiddling about with other settings, checking disks, defragmenting or pointlessly uninstalling "suspect" software to no avail.

  • The utility was written in Visual BASIC 5 and uses VBToolbox v1.19+. You can download it here (85kb ZIP file)
  • Only the PRIMARY channels on each bus are checked (I may add the other 2 devices later)
  • It is now a dual console/Windows application. You can have it run silently from your startup group using
    HDTEST /CHECK - use HDTEST /? for help and more information
  • The utility was inspired by the "IT Service Duck"'s article on the subject which helped me resolve problems with my own laptop
  • Microsoft Fix Page - IDE ATA and ATAPI disks use PIO mode after multiple time-out or CRC errors occur
    This page includes a link to request the hotfix by email for Windows Server 2008, Windows XP and Windows 2000

Page top


FAQ - Frequently Asked Questions

Q) Can I have the source code?
A) Sorry, no. This project as well as being offered free to anyone it might benefit would also form part of my personal "CV showcase" which I use when I apply for work. There may be a contractual expectation that code I produce is used by future employers and where this code is the same as that in VBToolbox there may be possible retrospective copyright problems which I just don't want to get into. It's easier for me just to say no at this point in time. I have no wish to get into the legal tangles which might ensue.

Q) I get a crash error message in VB relating to Data Execution Prevention (DEP) - why?
A) This is a Visual BASIC issue and is not related to VBToolbox. See the latest manual (V1.15).
Turn OFF global DEP in XP/SP2 or create an exception for the Visual BASIC IDE. This should only affect the IDE. Compiled programs should not be affected by DEP issues.
It occurs because certain areas of memory seem to have not been marked correctly as NX (no execute). VB5 was developed prior to XP/SP2 and DEP.

Q) Why bother writing something for a language which is nearly 10 years old?
A) I own a 100% legal and fully-licensed copy of VB 5. Like many miserable "old-gits" I'm a terminal-tightwad, and VB pretty well gets the job done for the stuff I need to write.  You can blitz together Windowed apps to do a job in no time at all. The language shortcomings which most experts whinge about are easily addressed by adding the features you need in "C" as a DLL. Few languages have made handling the Windowing aspect of development easier than VB did and I see no reason to fork out extra money when I can add new features so easily using this method. Developing parts of this will prove useful and has been absorbing and fun so why not?

There are also benefits in recycling BASIC programming skills with the advantage of calling ADO/MDB database library routines; in fact, calling pretty well anything on your system that a normal Visual BASIC program can access such as other DLLs, shell utilities or even other program languages.

Q) Are you not aware that PHP is a better/more-elegant/flexible solution?
A) Yes, I absolutely agree. I also like and use PHP. I support PHP 4 and 5 in MicroApache which I also maintain

Q) Can UPX compression be used with EXE programs produced by VB which link to VBToolbox?
A) Yes. Absolutely. The DLL is also supplied in UPX compressed format which reduces size by around 50%. It is not affected by re-LINKing as a console app.

Q) The need to use VBString as a wrapper kinda sucks - isn't there a way around this?
A) Yes it does, so from v1.11 onwards you only need to use VBString for functions which return non-ASCII range data which may contain embedded null characters which are not part of the returned data. This excludes BitPack which is designed to avoid returning NULL characters within the bounds of it's data area.

Q) Do I need any additional runtimes to run the test program?
A) Yes, if you are using an older version of Windows such as Windows 98 or NT. You can download them from here

Q) Can I call other DLLs and use them with say CGI etc.
A) Yes, you can "mix-and-match" libraries and call other DLLs just as you did before. VBToolbox just adds some new features which may make life easier. For example a library I often use and link to is the zlib.dll compression library.

Q) Why is this called MSLIB145?
A) No particular reason. I needed to pick a fairly random filename which would not clash with any other DLL.

Q) Is this DLL "thread-safe"?
A) It should be assumed NOT to be thread-safe. I haven't spent any time either developing or testing for multiple thread-use. Many functions return copies of statics and no function includes local-locking which means that their contents could change during processing. The library was written primarily for legacy VB 5/6 which are claimed not to be fully thread-safe in any event.

Q) Are string-returns such as RandomStr() limited to 255 characters?
A) No, generally, you can have "Long integer" counts of characters in most string functions; although creating strings of more than about 50,000 characters is likely to consume large amounts of memory and CPU-time. It may be easier on the CPU in such cases to create several smaller strings, handle separately and concatenate them later in your program.

Q) How do I declare links from VB to this DLL?
A) A complete example wrapper - mslib145.bas - is included with the test program and bundled with the ZIP distro. Just drag-and-drop it into your VB project-explorer window. There should be no need to edit the file unless you want to remove declarations you will never use.

Q) Does it work with Windows Vista?
A) No idea. I've deleted Vista from every new PC I own and installed XP instead. If it works with XP it should work with Vista (So they say).
A) Update: Tested and found to work well with Windows 7 build 7100 although Win7 is between 300% and 1000% slower than XP using the VBToolbox test code

Q) Does the library implement Unicode?
A) No. There are also no plans to implement Unicode support other than where this is an intrinsic programming requirement (such as when handling Variant strings). The module isn't going to get enough use by non-Unicode users to warrant the time required to migrate all of the functions to multibyte use. Also VB doesn't like being sent Unicode strings (BSTR) strings back via a function body. Where this has been tested you would need to use a StrConv() wrapper to convert back from Unicode to ANSI. The string arrives back as Unicode OK but isn't internally re-translated back again.

Q) Can you include function "x" in the library please?
A) I may consider adding a few other functions if they are feasible and not too unwieldy or time-consuming to develop. Send suggestions via the contact/feedback form

Q) I think I found a bug - what should I do?
A) Send as much information via the contact/feedback form - click here If detailed information is found to be required a contact email address will be provided. Sorry it has to be done this way but spammers are playing havoc with my email and I am getting around 12,000+ spams now every week.

Page top


Development, Testing and Feedback

  • The DLL functions can be called from any programming language which supports linkage to external DLLs – not just Visual BASIC but FreeBASIC, Visual FoxPro, VB for Apps (VBA), Excel etc.
  • I would be very interested to hear from anyone has tested this DLL in a) WINE or b) With other forms of BASIC than Microsoft's such as FreeBASIC.
  • The library is offered as freeware for educational use only and should not be used in production environments without thorough testing.
  • I may consider releasing the LIB file which would permit all of these routines to be used within "C"/C++ projects if there is enough interest

Page top

This page and software, unless otherwise stated, is Copyright (c) M Shaw

Last updated on 06 March 2021 - This page is designed 1024 x760 resolution displays