Snack card

Zeige deutsche Version

Last updated: page content on 05/13/2010, download contents on 04/21/2010

New! Even more to download: from here you can get a to be growing collection of nifty tools!


CEval and CEvalTester - scripting for Visual Basic
ukCheckBox - a comfortable replacement of the VB checkbox
VBRegTLBMod - playing typelib games
Hide - playing with steganographie
Sorttest - testing sort algorithms Update!
OddEven - the next one please!
ArrayDims - dead or alive
ToDate - safe conversion of DateTime strings
Strings - little string processing helpers
ukPopup - make a form being a popup or dropdown form
Cryptography - cryptographic helper classes
CZoom - zoom me up, Scotty! Update!
CFileSearch - scanning directories, searching files

CEval and CEvalTester - scripting for Visual Basic
VB6 binary application

CEval is a class for evaluating expressions in scripts. It uses a BASIC like syntax and tries to be as close as possible to the VB classic syntax.

CEvalTester is an application that allows the testing of CEval and also can serve as a powerful desktop calculator or simple spreadsheet replacement. CEvalTester embeds CEval and allows testing CEval to some extend.

Scripts can be entered, edited and loaded in CEvalTester's script window (the nearely white area in above picture). Then the script can be run. CEval in the first step compiles the script to sort of "bytecode" and then executes the "bytecode". Compilation and execution is very fast. In the status line on the picture above you can see the compilation and runtime CEval needed for the script.

After a script was compiled, the same "bytecode" can run as often as needed. Script variables can easily be accessed from the embedding application and altered between runs. The outputs from a run (the values of the evaluated expressions) are shown in an output window (the green area in above picture).

The output of the value of an evaluated expression into the output window follows following rules:

The current version of CEval is already production stable, however there will be some future feature additions and changes to the script syntax, so the "interface" is not stable yet. Main features to be added are user defined functions (inside the script and outside in the embedding application) and control flow constructs like decisions and loops. Also the use of objects will be assisted better and even creation of objects in script code will be possible then. So CEval will become a real script language, possibly as powerful as VB Script. The current version already is an advanced expression evaluator and comfortable desktop calculator replacement and can use objects.

Before it is feature complete I do not publish CEval nor CEvalTester in source. It is planned to later release CEval as a binary COM-Server dll and CEvalTester in source. The dll will be around 100 kB in size and can easily be embedded in any COM-aware development environment like VB classic.

Both then will be free to be used for personal purposes. For commercial uses the use of the CEval dll will be needed to be payed. Also for an extra fee the source of the CEval dll then can be bought.

In the archive there are two executables available: CEvalTester and CEvalCalculator. Both are identical and differ only in the name of the exe. And both exes are free for personal use.

CEvalCalculator always starts in calculator mode and can not be switched to test mode. See chapter "Run modes" in the application help (press "F1") for details.

Use CEvalCalculator if the main purpose is to use CEvalTester as a desktop calculator replacement or as a simple spreadsheet. Ideally suited for a quick calculation or for more complex calculations. Simply enter an expression and automagically the result appears in the output window during typing. Syntax errors are shown instantaneous, also runtime errors like a division by zero. In any case the error message tells what is wrong and which part of the script lead to the error. On demand the position of the offending part of the script is marked and shown in the script window.

All results are shown in the output window. From there they can be copied to the clipboard and also the output as a whole can be saved to a text file.

Also included in the archive are a help file and tutorial and example scripts.

For comments, more information or wishes about CEval you can send a mail to

Dependencies: uses some Windows APis, which should be present on all 32 Bit Windows systems (WIN 2K and above).

Download CEvalTester (version 1.2 from 1/18/2009)

ukCheckBox - a comfortable replacement of the VB checkbox
VB6 binary usercontrol with tester

Some peculiarities of the Visual Basic checkbox always have bothered me. Therefore I wrote a replacement for it, presented here. The user control depends only on the Visual Basic 6 runtimes and the "Marlett" font (which should be present on every windows system). It has its own graphical representation and properties and events being slightly different from the original:

New: now a tester app (with source code) is included in the download archive

The usercontrol has following dependencies:

The tester app has following dependencies:

Download ukCheckBox

VBRegTLBMod - playing typelib games
VB6 application

This tool is based on the tool VbRegTlb from SteveMcMahon. I did a little rewrite and extended it somewhat.

The tools purpose is to gain information and insight about type libraries, wether they are standalone files or embedded in a COM server file. Also it can be used to register and unregister type libraries and to find and remove "dead" type library entries in the registry. But beware: the tools deals with type libraries exclusively. You cannot eg register or unregister a COM server with it. You can register or unregister its typelibrary, although this is of little help without having re/unregistered all the other COM information as a complete COM server re/unregister would do.

This tool comes in to be very handy for managing the VB usercontrol typelib cache files (files with the extension .oca). Those are created from the VB IDE at will and their contained type library is registered in the registry. As VB creates new .oca files and registers them each time you do major changes on a user control under development and then uses it in the IDE for eg testing purposes, your system soon is cluttered with outdated .oca files. Unfortunately VB does not help you in getting rid of them. Deleting the files alone does not delete the registry entries too. This is where the tool comes in. Use it to identify outdated .oca files and then unregister them using the tool. Afterwards the file can be safely deleted.

Also, as said, standalone type libs (files usually ending with .tlb) can be registered and unregistered. Standalone type libs often are used to give a VB programmer comfortable access to API functions. Or some VB programmers like to define standalone type libs for their COM servers such separating type information and implementation in code. This gives better versioning management to them (instead of using the VB build in versioning management with the dreaded project and binary compatibility settings).

The tool can list your current type lib entries in the registry, where "dead" entries (entries missing the accompanying type lib file on disk) are marked. You get "dead" entries when you delete registered typelib files without prior unregistering or if you move a registered type lib file from one place on the disk to another. From the list you can select an entry and tell the tool to delete it from the registry.

Despite of being a pure type library handling tool it is also very handy in managing COM servers. Let's assume you find a file named xxx.dll on your disk and ask yourself:

The tool answers these and more questions.

The typelibviewer Oleview.exe and regedit.exe can be started from this tool (if available on your system). A (in experimental state) own registry viewer is included. With him a complete registry subbranch can be loaded and then its keys and values can be searched using a flexible search function.

!! ATTENTION !!

This tool is for advanced users only! You can damage your system down to death with it! Use it thoughtfully and at your own risk!

The tool is available as VB6 exe and has following dependencies:

Download VBRegTLBMod

Hide - playing with steganographie
VB6 application

Hide! is a toy with a serious background. A black and white bitmap (the mask) is encoded by using another black and white, but noisy, bitmap (the key). From the resulting bitmap (the code) the original bitmap can be retreived again by using the key again. The archive provided for download does contain some test bitmaps too.

For the mask a simple text editor is supplied allowing you to enter text in the mask. Also external black and white bitmaps of any content can be used as mask, which eg. could be the graphical image of some longer text. When the mask is encoded using Hide!, you get a secure version of it which can not be decoded by any means without having the key. Therefore store key and code separately and delete the mask!

The mask can be decoded "electronically" by using Hide! again or it can be decoded "physically".

The "electronic" method decodes losless, using the code and key as bitmap files.

The "physical" method principally is losless too. It uses printouts of the code and the key. For best results the mask should contain only text in big letters. Printout both on either thin paper or transparent paper. Use your favorite text editor or image processing program for printing. Look at the two printouts. Both show nothing else than noise. Then stack precisely one on the other and look at them with a bright light from the rear front. The hidden text from the mask will emerge.

For being able to position the printouts more precise, Hide! allows to embed markers in code and key. In Hide! set a printer precision of 50 dpi for getting big enough print outs.

Dependencies:

Download Hide

Sorttest - testing sort algorithms Update!
VB6 utility class with testapp und source

Sorttest is a program for testing and visualization of sorting algorithms. A range of sorting algorithms already are preimplemented. They also can be easily used in other programs.

Embedded in the program (available also as separate file) is an intensive help, now having its own more functional viewer. Have a look at the change log for reading all changes and extensions done to the current and older versions. The change log also is embedded in the program and available as separate text file. Both the change log and the help file inform you about the many changes, extensions and possibilities not mentioned on this web page.

The utility class CSort implements some well known sorting algorithms along with some variations of them:

One of the variants of the basic quicksort algorithm implements a "safe" version of quicksort. This variant eliminates the (although very unlikely) possibility of getting a stack overflow. The variant has the same sort speed as its base version. O(n*log(n)) sort behaviour for all kinds of number distributions is guaranteed. Like the quicksort basic routine it does sort already sorted arrays and the like without problems. Test yourself!

The utility class is made such that each of the implemented sorting algorithms is independent of the tester app. The user can easily embed his own algorithms for testing (see the inline comments in CSort) or also easily can extract one of the implemented algorithms for use in his own programs including adoption if necessary (again see the inline comments in CSort).

Each algorithm is implemented in two different, but functional identical, ways: in a fast mode optimized for speed and which can be used (just cut and paste) in your own code and in a stats mode allowing the measure of some statistical key figures:

All algorithms are implemented for an ascending sort of integral numbers of type Long. Adoption to other numerical types is easily done by changing type declarations. For sorting strings you should adapt comparisons and swaps too. Changing to descending sort can be done with most of the implementations by simply reversing the comparison directions.

Each algorithm has been carefully selected, uses common optimizations, has been tested and been implemented for maximum speed. Some of them have choosable parameter settings. The quicksort implementation is, despite of its amazingly shortness, highly efficient and is overwhelmingly robust against the distribution of the values to be sorted.

The accompanying test application allows you to test the sorts in 3 different modes:

Another class called CSortArrayGen delivers for the testing of the sorting algorithms lots of parameterized number distribution generators. Such one can test for how an algorithm is suited or behaves for distributions like already sorted, sorted descending, all equal or some special distributions like almost sorted. Some of the presented sorting algorithms are quite allergic on some distributions (execution times may jump up). CSortArrayGen again is made such that users can easily embed their own generators.

The number distributions created by the program can be saved to disk and loaded from disk (using a text format or a binary format). Also it is possible to create own number distribution text files using eg a text editor and to import them into the program. In the accompanying folder called "TestData" there already exist some files to play with. For having a look on and explanation of the very flexible text format and its possibilities see the file "TestData User entered.txt" in this folder.

For each number distribution some characteristics can be calculated: minimum value, maximum value and repetition count. The repetition count groups the values according to how often they are repeated. So there is one repetition group counting all unique values, one group counting all values that are present twice in the distribution and so on.

A further function allows the sorting result to be checked for correctness. So the user can test his own algorithms or modifications of the existing algorithms too.

A further highlight of the test application is its real time visual representation of the sorting progress. Choosable are point size, slow motion, single step mode and seamless scaling of the display. Additionally to single step mode breakpoints can be set at any place of the sort implementation. With them any informations about the inner state of the running sort at the time of hitting the breakpoint can be shown.

Different user settable shaded colours denoting changed and unchanged array elements allow a visual judgement of the sort efficiency in terms of assignments or swaps. Elements which are currently to be changed or swapped can be marked by showing them in a distinct color.

Besides the esthetic experience delivered by this visualization of the sorting progress this visualization also enables you to get a better grip of how the sorting algorithm works.

Also integrated is the display of the unsorted and sorted array numbers in 2 listboxes. They are disabled for arrays having more than ten thousand elements because then the filling of the listboxes is becoming very slow. Use them for controlling results (in case you want to check if the internal methods on assuring correctness are right :-))

Download Sorttest (Version 1.4.3 from 12/06/2009)

OddEven - the next one please!
VB6 quickie with source

Haven't you sought for long how to jump from a given integral number fastly to the neighbouring odd or even number? If so, come to a rest: you arrived. This quickie shows not one but five possibilities to do so.

I was inspired to this quickie from an article on AboutVB, which asks for such a solution (fast and preferably an one liner). The article is in german.

Download OddEven

ArrayDims - dead or alive
VB6 quickie with source

Arrays that live or are dead? But yes, they exist! And even better, arrays between death and life (I prefer to call them "zombies") are around. The quickie explains and shows how to differentiate between the three states an array can have. The code used takes you on a misterious road but hits the target.

More technical: we determine, if a dynamic array is (re)dimmed, if it has elements and how many dimensions it has (at max 60 dimensions are allowed in VB). And all this with a single function for any kind of array having any kind of element type. A very handy function also for param arrays or arrays eg returned from the Split function, which both in special cases return perfect "zombies".

Download ArrayDims

ToDate - safe conversion of DateTime strings
VB6 utility class with source

At times strings containing literal date or/and time values shall be converted to the VB type Date without any ambiguity. Such ambiguities stem from the deliberate conversions made by the VB build in functions CDate, DateValue, TimeValue and IsDate.

Firstly they take into account the current systems locales, which may not be appropriate, if the strings content comes from a eg text file your partner from overseas did send you (where perhaps a '*' is used as date separator or the like). On a german system (where the period "." is used as thousands separator), "29.2.1999" is interpreted by CDate as the 27th of february in 9900 without any complaint (CDate thinks it is the number 2921999).

And they try to guess what the content could be, if a string contains a date/time value in non standard format. Eg. "12.21.1999" (at least in Germany) can be a faulty content or (like CDate does) can be interpreted as the 21th of december in 1999. Even better, "1999.12.21" also is interpreted by CDate as the 21th of december in 1999. Plain numbers like "1000" are converted, in this case to the 26th of september in 1902.

Shorthands for year values are allowed. 2 digit year numbers are (according to rules set in the Windows system) converted to 4 digit year numbers. The result may be surprising the one or the other unaware of the doings behind the scenes. Remember the "year 2K" problem ?

And last but not least, CDate is buggy. "0000000000000000000000000000001.1.100" on my (german system) is converted to (in german notation) "01.01.0100", but "00000000000000000000000000000001.1.100" (which has one more leading zero) is converted to "22.05.1930".

As it should be clear from the above, in many cases for the sake of being non ambigous and having strict error detection, a self build function has to be used instead of CDate.

So here comes a class CDateTime with its function ToDate. It is faster (when compiled to native code) than VBs CDate conversion function and has following features:

ToDate converts strings with dates, times or date and times into the VB type Date.

ToDate is suited to check date and/or time strings for correctness as well as for fast conversion of greater amounts of date/time strings (like when converting data from a file). So she can replace the VB CDate and IsDate functions.

The downloadable archive contains, besides the class CDateTime, a tester application for comparing the performance and results of ToDate and CDate and a file Info.txt with some examples of date/time literals and their outcome after using CDate (as it is on a german window system).

Download ToDate

Strings - little string processing helpers
VB6 utility class with source

The current version V1.5 of class CStrings from 12.29.2003 has a bug fixed in method "NormalizeWS".

CStrings deals with white space (WS) in UNICODE strings. All UNICODE characters below &H21 are considered as WS. It trims, removes completely or normalizes (quenching a sequence of WS into on space character) WS from strings. And its done fast.

As bonus feature a fast replacement of the VB6 Replace function is included. The original source comes from Olaf Schmidt and has been a contest winner (or at least been the second winner) at the VB speed contest site. Those who know Olaf and already have seen some of his (as usual first class) code will perhaps being pleased that I rewrote it a little and heavily commented it, such becoming more "legible" ;-).

Download Strings V1.5

ukPopup - make a form being a popup or dropdown form
VB6 usercontrol with source and tester

The usercontrol automatically transforms a form to a popup or dropdown form. Just drop the control on an ordinary form, write one line of code and on you go. This control's advantage, compared with other's solutions, is: all key events and mouse events are left intact. And the form may contain nearly any other controls, which will do their job as usual, undisturbed by the popup mechanism.

Download ukPopup

Cryptography - cryptographic helper classes
VB6 classes with source

For some everyday cryptographic jobs here are some helper classes. They will be extended in the future by more helper classes or by extended helper classes. At the moment you get:

All classes have been proven to be correct (by doing tests and using publicly available test vectors), are trimmed to work at maximum speed and offer extra functionality exceeding the basic functionality. CBase64 can parse Base64 code embedded in surrounding text (as found eg in emails), can output formatted Base64 code ready to embed in emails (broken into lines of arbitrary length) and, when decoding, detects invalid formats (invalid characters, wrong length, wrong padding). The CRC32 implementation is able to sum up the CRC from several parts (such building a 'running' CRC). CCipher can create GUIDs and use them as keys (with choosable key length), can advance without en/decoding, can deliver 1 to 8 byte integral random numbers and can use an additional OneTimePad. The ARC4 algorithm which is used by CCipher is believed to yield identical results to the famous RC4 algorithm.

All classes use common functionality implemented in the accompanying modules MCommon and MVarInfo. MCommon implements diverse checks used for checking input parameters to some of the class methods. Most often array params are checked (eg wether they are 1-dimensional, zero-indexed, containing at least one element and so on).

MVarInfo implements one function gGetVarInfo, which accepts one parameter having any legal VB type (except arrays of element type fixed string). gGetVarInfo analyzes the parameter and gives back (using an UDT) the information found. This information (type, array characteristics and so on) then is used from various functions in MCommon.

Download Cryptography

CZoom - zoom me up, Scotty! Update!
VB6 class with source and testapp

A class CZoom zooming screen areas, whose position is determined by the current mouse cursor, to forms, pictureboxes or usercontrols. The accompanying test app is usable as a screen magnifier. CZoom is fast, therefore high zoom factors and large capture areas are possible. The settings of the test app are available from a right click context menu.

In version 1.0 under very rare circumstances memory leaking could occur. Version 1.1 fixes this. V1.2 has more bug fixes and adds a blinking cursor.

Download CZoom V1.2

CFileSearch - scanning directories, searching files
VB6 class with source and testapp

CFileSearch scans directories, starting from a root dir (which may be the disk root). It reads all items in a dir (files and subdirs, also hidden or system files and subdirs). Then it stores the subdir data (name, attributes, file times and more) internally. Also for those files in the scanned dir matching a given file name filter the file data (name, size, attributes and file times) is stored internally too.

A search scans subdirs recursively, that is it performs a recursive file search. The depth of the search can be constrained by giving the maximum drill down depth. So all dirs on all levels below the root dir could be scanned or only those of the first level below, or all up to the second level below and so on.

After a scan (or name it file search) the dir and file data are available in memory for further processing. Additionally the data gathered during a search can be saved to disk and read back later. The dir and file names can be returned sorted using various ordering criteria. Also the dirs can be sorted in hierarchical order.

CFileSearch uses the windows find file apis (FindFirstFile, FindNextFile and FindClose). If the Unicode versions of them are available on the system CFileSearch is running, those can be used (which speeds up things and allows for long pathes and file names up to about 32000 chars), otherwise the ANSI apis are used (restricting pathes and names to a length lower than 260 chars). On demand during a search the class can raise events for each dir and matching file it processes. In the event all data for the dir or the matching file is available and the user can decide, based upon this data, to not scan this dir or gather this file's data by cancelling the processing.

One can set a file name filter. The data for files matching the filter (so called "found" files) is gathered, the data for not matching files is not. Two special filters are available, matching all files or no file. More than one filter expression can be specified and the matching then will be done concurrently on all filter expressions: if a file name matches at least one of the filter expressions, it's data is gathered, otherwise not. Also matching can be reversed. Then files are gathered that do not match the given filter criteria. For matching the filter expressions use the Visual Basic Like syntax, so expressive filters can be build.

CFileSearch is optimized for speed and runs very fast even in the IDE. Also you can (as the tester app does, see the compile tab in the project properties) and should compile to native code, with all speed options set to squeeze out some extra speed in the compiled version. It outperforms by far all solutions using the VB Dir function or the file system object.

Eg on my old system (WIN2K, PIII at 550MHz, 256 MB Ram) a complete scan for all files of drive C is done in roughly 1.5 secs (on the second run, after the system has cached the search from the first run). Look at the screen shot above, showing the results of this search. Drive C has 2001 directories, all of them have been scanned. For one dir ("System Volume Information", a system dir) access had been denied. 18240 files in 1293 dirs have been found. As the search was done with matching to all files, the count of the found files is equal to the count of existing files.

The class comes along with a tester application and a directory tree for testing (having empty files only).

Some use cases for CFileSearch:

Dependencies: uses some WIN apis, which should be available on all 32 bit windows systems (WIN NT and above, WIN95 and above).

Download CFileSearch V1.1